| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267 |
- <template>
- <ele-modal
- :title="dialogTitle"
- :visible.sync="visible"
- :before-close="handleClose"
- :close-on-click-modal="false"
- :close-on-press-escape="false"
- width="80%"
- :maxable="true"
- append-to-body
- destroy-on-close
- >
- <el-form
- label-width="115px"
- :model="formData"
- :rules="formRules"
- ref="formRef"
- v-loading="loading"
- :disabled="type == 'detail'"
- >
- <el-row>
- <el-col :span="8">
- <el-form-item label="行业类别" prop="industryType">
- <el-select
- v-model="formData.industryType"
- placeholder="请选择行业类别"
- style="width: 100%"
- @change="industryTypeChange"
- >
- <el-option
- v-for="item in industryTypeList"
- :key="item.value"
- :label="item.label"
- :value="item.value"
- />
- </el-select>
- </el-form-item>
- </el-col>
- <el-col :span="8">
- <el-form-item label="业务分类" prop="businessType">
- <el-select
- v-model="formData.businessType"
- placeholder="请选择业务分类"
- style="width: 100%"
- @change="businessTypeChange"
- :disabled="!!businessType"
- >
- <el-option
- v-for="item in businessTypeList"
- :key="item.value"
- :label="item.label"
- :value="item.value"
- />
- </el-select>
- </el-form-item>
- </el-col>
- <el-col :span="8">
- <el-form-item label="模块划分" prop="reportWorkType">
- <el-select
- v-model="formData.reportWorkType"
- placeholder="请选择模块划分"
- style="width: 100%"
- @change="reportWorkTypeChange"
- >
- <el-option
- v-for="item in reportWorkTypeList"
- :key="item.value"
- :label="item.label"
- :value="item.value"
- />
- </el-select>
- </el-form-item>
- </el-col>
- <el-col :span="8">
- <el-form-item label="应用场景" prop="classify">
- <el-select
- v-model="formData.classify"
- placeholder="请选择应用场景"
- style="width: 100%"
- @change="classifyChange"
- >
- <el-option
- v-for="item in classifyList"
- :key="item.value"
- :label="item.label"
- :value="item.value"
- />
- </el-select>
- </el-form-item>
- </el-col>
- <el-col :span="8">
- <el-form-item label="模板样式" prop="recordTemplateStyle">
- <el-select
- v-model="formData.recordTemplateStyle"
- placeholder="请选择模板样式"
- style="width: 100%"
- >
- <el-option
- v-for="item in recordTemplateStyleList"
- :key="item.value"
- :label="item.label"
- :value="item.value"
- />
- </el-select>
- </el-form-item>
- </el-col>
- <el-col :span="8">
- <el-form-item label="编码" prop="code">
- <el-input
- v-model="formData.code"
- :disabled="true"
- placeholder="系统自动生成"
- ></el-input>
- </el-form-item>
- </el-col>
- <el-col :span="8">
- <el-form-item label="版本">
- <el-input
- :value="versionText"
- disabled
- placeholder="系统自动生成"
- ></el-input>
- </el-form-item>
- </el-col>
- <el-col :span="8">
- <el-form-item label="名称" prop="name">
- <el-input
- v-model="formData.name"
- placeholder="请输入"
- :disabled="type == 'processEdit'"
- ></el-input>
- </el-form-item>
- </el-col>
- <el-col :span="8">
- <el-form-item
- label="启用日期"
- prop="startDate"
- :rules="
- businessType != 3
- ? [
- {
- required: true,
- message: '请选择启用日期',
- trigger: 'blur'
- },
- {
- required: true,
- message: '请选择启用日期',
- trigger: 'change'
- },
- { validator: validateStartDate, trigger: 'change' }
- ]
- : []
- "
- >
- <el-date-picker
- v-model="formData.startDate"
- type="date"
- placeholder="请选择启用日期"
- style="width: 100%"
- :picker-options="{
- disabledDate: (time) =>
- time.getTime() < new Date(new Date().toDateString()).getTime()
- }"
- :disabled="type == 'processEdit'"
- />
- </el-form-item>
- </el-col>
- <el-col :span="8">
- <el-form-item
- label="停用日期"
- prop="stopDate"
- :rules="
- businessType != 3
- ? [
- {
- required: true,
- message: '请选择停用时间',
- trigger: 'change'
- },
- { validator: validateStopDate, trigger: 'change' }
- ]
- : []
- "
- >
- <el-date-picker
- v-model="formData.stopDate"
- type="date"
- placeholder="请选择停用日期"
- style="width: 100%"
- :disabled="type == 'processEdit'"
- />
- </el-form-item>
- </el-col>
- <!-- <el-col :span="8">
- <el-form-item label="物联设备" prop="stopDate">
-
- </el-form-item>
- </el-col> -->
- <el-col
- v-if="
- (formData.recordTemplateStyle == '2' && this.businessType != 3) ||
- formData.reportWorkType == 5
- "
- :span="8"
- >
- <el-form-item label="关联设备" prop="deviceName" required>
- <el-input
- v-model="formData.deviceName"
- placeholder="请选择设备"
- :readonly="true"
- >
- <template #append>
- <el-button @click="selectDeviceId">选择设备</el-button>
- </template>
- </el-input>
- </el-form-item>
- </el-col>
- <el-col
- v-if="formData.reportWorkType == 2 && this.businessType != 3"
- :span="8"
- >
- <el-form-item label="关联工序">
- <el-input
- v-model="formData.produceTaskName"
- @click.native="openProduceTaskDialog"
- readonly
- placeholder="关联工序"
- clearable
- :disabled="type == 'processEdit'"
- >
- <i
- v-if="formData.produceTaskName"
- slot="suffix"
- class="el-input__icon el-icon-close"
- size="24"
- @click.stop="clearProductTask"
- ></i>
- </el-input>
- </el-form-item>
- </el-col>
- <el-col
- v-if="formData.reportWorkType == 2 && this.businessType != 3"
- :span="8"
- >
- <el-form-item label="是否有执行方式" label-width="130px">
- <el-radio-group
- v-model="formData.isExecuteMethod"
- @change="isExecuteMethodChange"
- >
- <el-radio :label="1">是</el-radio>
- <el-radio :label="0">否</el-radio>
- </el-radio-group>
- </el-form-item>
- </el-col>
- <el-col
- v-if="
- formData.isExecuteMethod == 1 &&
- formData.reportWorkType == 2 &&
- this.businessType != 3
- "
- :span="8"
- >
- <el-form-item label="执行方式" required prop="executeMethodId">
- <el-select
- v-model="formData.executeMethodId"
- filterable
- placeholder="请选择"
- style="width: 100%"
- @change="executeMethodIdChange"
- >
- <el-option
- v-for="item in executeMethodList"
- :key="item.id"
- :label="item.name"
- :value="item.id"
- >
- </el-option>
- </el-select>
- </el-form-item>
- </el-col>
- </el-row>
- <el-row v-if="businessType != 3">
- <el-col :span="24">
- <el-form-item label="周期" prop="frequencyValue" required>
- <rule-cycle
- ref="cycleMultipleRef"
- :formData="formData"
- :pageType="type"
- :isBindPlan="type == 'processEdit'"
- />
- </el-form-item>
- </el-col>
- </el-row>
- <header-title title="规则明细" v-if="businessType != 3"> </header-title>
- <el-tabs
- v-if="formData.recordTemplateStyle == '4' && businessType != 3"
- v-model="statisticsType"
- type="card"
- >
- <el-tab-pane
- v-for="i in statisticsTypeList"
- :label="i.label"
- :name="i.value"
- :key="i.value"
- >
- </el-tab-pane>
- </el-tabs>
- <ele-pro-table
- v-if="businessType != 3"
- ref="table"
- :columns="bankColumns"
- :datasource="detialsDatasource"
- :need-page="false"
- row-key="id"
- class="table_list"
- :cache-key="cacheKeyUrl"
- >
- <template v-slot:toolbar>
- <div style="display: flex; align-items: center; gap: 10px">
- <el-button
- type="primary"
- icon="el-icon-plus"
- class="ele-btn-icon"
- @click="addRow"
- >
- 新建
- </el-button>
- <el-button
- type="primary"
- icon="el-icon-plus"
- class="ele-btn-icon"
- @click="bindSubstanceListOpen"
- v-if="formData.reportWorkType == 5"
- >
- 添加物联参数
- </el-button>
- </div>
- </template>
- <template v-slot:sortNum="{ row }">
- <el-input-number
- style="width: 80px"
- v-model.number="row.sortNum"
- placeholder="请输入排序"
- size="mini"
- type="number"
- :min="1"
- controls-position="right"
- ></el-input-number>
- </template>
- <template v-slot:paramType="{ row }">
- <el-select
- v-model="row.paramType"
- placeholder="请选择参数类型"
- size="mini"
- @change="paramTypeChange(row)"
- :disabled="!!row.paramCode"
- >
- <el-option label="数值" :value="1" />
- <el-option label="选择" :value="2" />
- <el-option label="上下限" :value="3" />
- <el-option label="规格" :value="4" />
- <el-option label="时间" :value="5" />
- <el-option label="范围" :value="6" />
- <el-option label="文本" :value="7" />
- <!-- <el-option label="枚举" :value="8" /> -->
- <el-option label="计算" :value="9" />
- </el-select>
- </template>
- <template v-slot:paramValue="{ row }">
- <!-- 根据参数类型渲染不同的输入组件 -->
- <el-link
- v-if="formData.recordTemplateStyle == '3'"
- :underline="false"
- style="cursor: pointer"
- >
- <div class="ele-cell">
- <div @click="selectChooseModalProduct(row)">
- {{ row.productName ? row.productName : '请选择产品' }}
- </div>
- <i
- v-if="row.tools.length == 0"
- class="el-icon-arrow-down"
- @click="selectChooseModalProduct(row)"
- ></i>
- <i v-else class="el-icon-close" @click="clearProduct(row)"></i>
- </div>
- </el-link>
- <el-input
- v-else
- v-model="row.paramValue"
- placeholder="请输入参数内容"
- size="mini"
- type="textarea"
- rows="1"
- autosize
- ></el-input>
- </template>
- <template v-slot:formula="{ row }">
- <div v-if="row.paramType == 9" class="formula-builder">
- <div class="formula-builder__selects">
- <!-- 选择参数:从已填的非计算参数内容里取 -->
- <el-select
- v-model="row._paramSelect"
- placeholder="选择参数"
- size="mini"
- style="width: 100px; margin-right: 8px; flex-shrink: 0"
- @change="paramSelectChange($event, row)"
- >
- <el-option
- v-for="item in getSelectOptionsByDetails(row.statisticsType)"
- :key="item.value"
- :label="item.label"
- :value="item.value"
- />
- </el-select>
- <!-- 选择运算符 -->
- <el-select
- v-model="row._opSelect"
- :key="row._opSelect + '_opSelect'"
- placeholder="选择符号"
- size="mini"
- style="width: 100px; flex-shrink: 0"
- @change="opSelectChange($event, row)"
- >
- <el-option
- v-for="op in opSelectOptions"
- :key="op"
- :label="op"
- :value="op"
- />
- </el-select>
- <!-- 替换或者追加 -->
- <el-select
- v-if="row.activeIndex != undefined"
- v-model="row._replaceOrAppend"
- :key="row._replaceOrAppend + 'row._replaceOrAppend'"
- placeholder="选择"
- size="mini"
- style="width: 80px; margin-left: 8px; flex-shrink: 0"
- >
- <el-option key="append" label="追加" value="append" />
- <el-option key="replace" label="替换" value="replace" />
- </el-select>
- </div>
- <!-- 已组装公式标签展示 -->
- <div
- v-if="row.formulaParts && row.formulaParts.length"
- style="display: inline-flex; flex-wrap: wrap; max-width: 100%"
- >
- <el-tag
- v-for="(p, index) in row.formulaParts"
- :key="index"
- size="mini"
- closable
- :type="row.activeIndex === index ? 'primary' : 'info'"
- @click="formulaPartsTagClick(index, row)"
- @close="tagItemDelete(index, row)"
- >
- {{ p }}
- </el-tag>
- </div>
- <!-- 公式字符串展示(只读) -->
- <el-input
- v-if="row.formulaParts && row.formulaParts.length"
- :value="row.formulaParts.join('')"
- size="mini"
- type="textarea"
- disabled
- placeholder="公式"
- style="margin-top: 6px"
- />
- </div>
- </template>
- <template v-slot:defaultValue="{ row }">
- <el-row>
- <el-col :span="12">
- <!-- <el-select
- v-if="row.paramType != 7"
- v-model="row.symbol"
- placeholder="请选择"
- size="mini"
- >
- <el-option label=">" value=">"> </el-option>
- <el-option label="<" value="<"> </el-option>
- <el-option label="!=" value="!="> </el-option>
- <el-option label=">=" value=">="> </el-option>
- <el-option label="<=" value="<="> </el-option>
- <el-option label="~~" value="~~"> </el-option>
- <el-option label="+-" value="+-"> </el-option>
- <el-option label="......" value="......"> </el-option>
- </el-select> -->
- <DictSelection
- v-if="row.paramType != 7"
- clearable
- dictName="数学字符"
- v-model="row.symbol"
- placeholder="请选择逻辑"
- size="mini"
- ></DictSelection>
- </el-col>
- <el-col :span="row.paramType != 7 ? 12 : 24">
- <el-input
- v-model="row.defaultValue"
- placeholder="请输入默认值"
- size="mini"
- ></el-input>
- </el-col>
- </el-row>
- </template>
- <template v-slot:maxValue="{ row }">
- <el-input
- v-if="row.paramType == 3 || row.paramType == 6"
- v-model="row.maxValue"
- placeholder="请输入参数上限"
- size="mini"
- ></el-input>
- <span v-else-if="row.paramType == 7 && row.paramCode">{{
- row.maxValue
- }}</span>
- </template>
- <template v-slot:minValue="{ row }">
- <el-input
- v-if="row.paramType == 3 || row.paramType == 6"
- v-model="row.minValue"
- placeholder="请输入参数下限"
- size="mini"
- ></el-input>
- <span v-else-if="row.paramType == 7 && row.paramCode">{{
- row.minValue
- }}</span>
- </template>
- <template v-slot:unitName="{ row }">
- <!-- <el-input
- v-model="row.unitName"
- placeholder="请输入参数单位"
- size="mini"
- ></el-input> -->
- <DictSelection
- v-if="row.paramType != 7"
- dictName="工艺参数单位"
- clearable
- filterable
- v-model="row.unitName"
- size="mini"
- >
- </DictSelection>
- <span v-else-if="row.paramType == 7 && row.paramCode">{{
- row.unitName
- }}</span>
- </template>
- <template v-slot:toolName="{ row, $index }">
- <el-link :underline="false" style="cursor: pointer">
- <div class="ele-cell">
- <div @click="handleAdd(row, '', 'toolName')">
- {{
- row.tools && row.tools.length > 0
- ? row.tools.map((i) => i.toolName).join(',')
- : '请选择'
- }}
- </div>
- <i
- v-if="row.tools.length == 0"
- class="el-icon-arrow-down"
- @click="handleAdd(row, '', 'toolName')"
- ></i>
- <i
- v-else
- class="el-icon-close"
- @click="clearTool(row, '', 'toolName')"
- ></i>
- </div>
- </el-link>
- </template>
- <template v-slot:substanceName="{ row, $index }">
- <el-link :underline="false" style="cursor: pointer">
- <div class="ele-cell">
- <div @click="handleAdd(row, $index, 'substanceName')">
- {{ row.substanceName || '请选择' }}
- </div>
- <i
- v-if="!row.substanceName"
- class="el-icon-arrow-down"
- @click="handleAdd(row, $index, 'substanceName')"
- ></i>
- <i
- v-else
- class="el-icon-close"
- @click="clearTool(row, $index, 'substanceName')"
- ></i>
- </div>
- </el-link>
- </template>
- <template v-slot:toolCodes="{ row }">
- <el-input
- :value="
- row.tools && row.tools.length > 0
- ? row.tools.map((i) => i.toolCode).join(',')
- : ''
- "
- placeholder="自动带出"
- disabled
- size="mini"
- ></el-input>
- </template>
- <template v-slot:substanceCode="{ row }">
- <el-input
- :value="row.substanceCode"
- placeholder="自动带出"
- disabled
- size="mini"
- ></el-input>
- </template>
- <template v-slot:remark="{ row }">
- <el-input
- v-model="row.remark"
- placeholder="请输入"
- size="mini"
- ></el-input>
- </template>
- <template v-slot:action="{ row }">
- <el-link
- v-if="type != 'detail'"
- type="danger"
- :underline="false"
- icon="el-icon-delete"
- @click="deleteRow(row)"
- >
- 删除
- </el-link>
- </template>
- </ele-pro-table>
- <header-title
- :title="
- formData.reportWorkType == 1
- ? '实验过程'
- : formData.reportWorkType == 2
- ? '实验记录'
- : ''
- "
- v-if="businessType == 3"
- >
- </header-title>
- <experimentationProcess
- :edit="type != 'detail'"
- :readonly="type == 'detail'"
- v-if="businessType == 3"
- ref="experimentationProcess"
- ></experimentationProcess>
- </el-form>
- <template v-slot:footer>
- <el-button
- v-if="type != 'detail' && type != 'processEdit'"
- :loading="btnLoading"
- type="primary"
- @click="saveAndPublish"
- >
- 保存并发布
- </el-button>
- <el-button
- v-if="type != 'detail' && type != 'processEdit'"
- :loading="btnLoading"
- type="primary"
- @click="confirm"
- >
- 保存
- </el-button>
- <el-button
- v-if="type == 'processEdit'"
- :loading="btnLoading"
- type="primary"
- @click="processEditSave"
- >
- 保存
- </el-button>
- <el-button :loading="btnLoading" @click="handleClose">取消</el-button>
- </template>
- <toolModal ref="toolModalRef" @chooseModal="chooseModal" />
- <toolModal
- ref="toolModalTowRef"
- @chooseModal="chooseModalProduct"
- :multiple="false"
- />
- <MaterialAdd
- ref="deviceSelectDialog"
- selectType="single"
- @chooseEquipment="chooseEquipment"
- :multiple="false"
- />
- <bindSubstanceList
- ref="bindSubstanceRef"
- @bindSubstanceSuccess="bindSubstanceSuccess"
- ></bindSubstanceList>
- <ProductModal
- ref="ProductModalRef"
- @changeProduct="changeProduct"
- ></ProductModal>
- <processModal
- ref="processModalRef"
- @chooseProcess="processChooseProcess"
- ></processModal>
- </ele-modal>
- </template>
- <script>
- //设备初始化字段
- const substanceKey = [
- 'substanceCode',
- 'substanceId',
- 'substanceName',
- 'paramCode',
- 'paramValue',
- 'maxValue',
- 'minValue',
- 'unitName'
- ];
- import { getByCode } from '@/api/system/dictionary-data';
- // import RuleCycle from '../../matterRules/components/rule-cycle.vue';
- import RuleCycle from './rule-cycle.vue';
- import OperationGuideDialog from '@/views/rulesManagement/matterRules/components/operationGuideDialog.vue';
- import Details from './details.vue';
- import dictMixins from '@/mixins/dictMixins';
- import toolModal from './toolModal.vue';
- import bindSubstanceList from './bindSubstanceList.vue';
- import MaterialAdd from '../../components/MaterialAdd.vue';
- import {
- recordrulesSave,
- recordrulesDetailPage,
- recordrulesUpdate,
- recordrulesPublish,
- recordrulesSaveAndPublish,
- recordrulesUpdateVersion,
- recordrulesCyclePage,
- recordrulesGetById,
- recordrulesTypePage
- } from '@/api/recordrules/index';
- import ProductModal from '@/components/selectProduct/ProductModal.vue';
- import { getTreeByPid } from '@/api/classifyManage';
- import processModal from './processModal.vue';
- import experimentationProcess from './experimentationProcess.vue';
- import ProductModalCorrelation from './ProductModal.vue';
- import { recordrulesexecutemethodPage } from '@/api/recordrulesexecutemethod/index';
- import { businessTypeList } from '@/views/regulationManagement/components/util';
- export default {
- mixins: [dictMixins],
- components: {
- OperationGuideDialog,
- RuleCycle,
- Details,
- ProductModal,
- MaterialAdd,
- toolModal,
- processModal,
- ProductModalCorrelation,
- experimentationProcess,
- bindSubstanceList
- },
- props: {
- typeInfo: {
- type: Object,
- default: () => null
- },
- businessType: ''
- },
- computed: {
- bankColumns() {
- let list = [
- {
- width: 110,
- type: 'index',
- columnKey: 'index',
- align: 'center',
- label: '序号'
- },
- {
- prop: 'sortNum',
- label: '排序',
- align: 'center',
- slot: 'sortNum',
- minWidth: 110
- },
- {
- prop: 'paramType',
- label: '参数类型',
- align: 'center',
- slot: 'paramType',
- minWidth: 110
- },
- {
- prop: 'paramValue',
- label: '参数内容',
- align: 'center',
- slot: 'paramValue',
- minWidth: 261
- },
- {
- prop: 'iotPointName',
- label: '物联点位',
- align: 'center',
- minWidth: 150
- },
- {
- prop: 'formula',
- label: '计算公式',
- align: 'center',
- slot: 'formula',
- minWidth: 300
- },
- {
- prop: 'defaultValue',
- label: '默认值',
- align: 'center',
- slot: 'defaultValue',
- minWidth: 150
- },
- {
- prop: 'maxValue',
- label: '参数上限',
- align: 'center',
- slot: 'maxValue',
- minWidth: 110
- },
- {
- prop: 'minValue',
- label: '参数下限',
- align: 'center',
- slot: 'minValue',
- minWidth: 110
- },
- {
- prop: 'unitName',
- label: '参数单位',
- align: 'center',
- slot: 'unitName',
- minWidth: 110
- },
- {
- prop: 'substanceName',
- label: '设备名称',
- align: 'center',
- slot: 'substanceName',
- minWidth: 110
- },
- {
- prop: 'substanceCode',
- label: '设备编码',
- align: 'center',
- slot: 'substanceCode',
- minWidth: 110
- },
- {
- prop: 'toolName',
- label: '工具名称',
- align: 'center',
- slot: 'toolName',
- minWidth: 110
- },
- {
- prop: 'toolCodes',
- label: '工具编码',
- align: 'center',
- slot: 'toolCodes',
- minWidth: 110
- },
- {
- prop: 'remark',
- label: '备注',
- align: 'center',
- slot: 'remark',
- minWidth: 110
- },
- {
- columnKey: 'action',
- label: '操作',
- width: 110,
- align: 'center',
- resizable: false,
- slot: 'action',
- fixed: 'right'
- }
- ];
- if (this.formData.recordTemplateStyle != '4') {
- // 过滤掉 计算公式 列
- list = list.filter((i) => i.prop != 'formula');
- }
- if (this.formData.reportWorkType != 5) {
- list = list.filter(
- (i) => !['substanceName', 'substanceCode'].includes(i.prop)
- );
- }
- return list;
- },
- versionText() {
- if (this.type == 'change') {
- return '系统自动生成';
- }
- return (
- this.formData.bigVersion +
- this.formData.versionMark +
- this.formData.smallVersion
- );
- },
- productColumns() {
- return [
- {
- columnKey: 'index',
- type: 'index',
- width: 45,
- align: 'center',
- reserveSelection: true
- },
- {
- prop: 'code',
- label: '产品编码'
- },
- {
- prop: 'name',
- label: '产品名称',
- showOverflowTooltip: true
- },
- {
- prop: 'brandNum',
- label: '牌号'
- },
- {
- prop: 'modelType',
- label: '型号'
- },
- {
- prop: 'specification',
- label: '规格'
- },
- {
- prop: 'measuringUnit',
- label: '计量单位'
- },
- {
- prop: 'packingUnit',
- label: '包装单位'
- },
- {
- columnKey: 'action',
- label: '操作',
- width: 110,
- align: 'center',
- resizable: false,
- slot: 'action',
- fixed: 'right'
- }
- ];
- },
- cacheKeyUrl() {
- return `main-permit-add-2510181429-reportWorkType`;
- },
- detialsDatasource() {
- if (this.formData.recordTemplateStyle == '4') {
- // 根据 statisticsType 过滤
- return this.formData.details.filter(
- (i) => i.statisticsType == this.statisticsType
- );
- } else {
- return this.formData.details;
- }
- },
- // 根据typeList 计算行业类型列表
- // {
- // "id": "1991058936943173633",
- // "createTime": "2025-11-19 16:20:17",
- // "createUserId": "1881891196703911938",
- // "industryType": 1,
- // "industryName": "工程机械",
- // "businessType": 1,
- // "businessName": "生产",
- // "reportWorkType": 1,
- // "reportWorkName": "产前准备",
- // "sceneType": 1,
- // "sceneName": "清场清洁",
- // "templateStyleType": 1,
- // "templateStyleName": "通用模板",
- // "tenantId": "1",
- // "deptId": "1",
- // "factoriesId": "1916747066214232065"
- // }
- industryTypeList() {
- const seen = new Set();
- const res = [];
- for (const i of this.typeList || []) {
- const key = String(i.industryType);
- if (!seen.has(key)) {
- seen.add(key);
- res.push({
- label: i.industryName,
- value: key
- });
- }
- }
- return res;
- },
- // 根据typeList和formData.industryType计算业务分类列表
- businessTypeList() {
- const seen = new Set();
- const res = [];
- const list = this.typeList.filter(
- (i) => i.industryType == this.formData.industryType
- );
- for (const i of list || []) {
- const key = String(i.businessType);
- if (!seen.has(key)) {
- seen.add(key);
- res.push({
- label: i.businessName,
- value: key
- });
- }
- }
- return res;
- },
- // 根据typeList和formData.industryType、formData.businessType计算模块划分列表
- reportWorkTypeList() {
- const seen = new Set();
- const res = [];
- const list = this.typeList.filter(
- (i) =>
- i.industryType == this.formData.industryType &&
- i.businessType == this.formData.businessType
- );
- for (const i of list || []) {
- const key = String(i.reportWorkType);
- if (!seen.has(key)) {
- seen.add(key);
- res.push({
- label: i.reportWorkName,
- value: key
- });
- }
- }
- return res;
- },
- // 根据typeList和formData.industryType、formData.businessType、formData.reportWorkType计算应用场景列表
- classifyList() {
- const seen = new Set();
- const res = [];
- const list = this.typeList.filter(
- (i) =>
- i.industryType == this.formData.industryType &&
- i.businessType == this.formData.businessType &&
- i.reportWorkType == this.formData.reportWorkType
- );
- for (const i of list || []) {
- const key = String(i.sceneType);
- if (!seen.has(key)) {
- seen.add(key);
- res.push({
- label: i.sceneName,
- value: key
- });
- }
- }
- return res;
- },
- // 根据typeList和formData.industryType、formData.businessType、formData.reportWorkType、formData.classify计算模板样式列表
- recordTemplateStyleList() {
- const seen = new Set();
- const res = [];
- const list = this.typeList.filter(
- (i) =>
- i.industryType == this.formData.industryType &&
- i.businessType == this.formData.businessType &&
- i.reportWorkType == this.formData.reportWorkType &&
- i.sceneType == this.formData.classify
- );
- for (const i of list || []) {
- const key = String(i.templateStyleType);
- if (!seen.has(key)) {
- seen.add(key);
- res.push({
- label: i.templateStyleName,
- value: key
- });
- }
- }
- return res;
- }
- },
- data() {
- const formDateBase = {
- id: null,
- deviceId: null,
- deviceName: '',
- frequencyUnit: 2,
- frequencyValue: null,
- name: '',
- details: [],
- recordRulesCycleList: [],
- startDate: null,
- stopDate: null,
- version: 1,
- code: '',
- fromId: null,
- // 行业类型
- industryType: null,
- // 业务分类
- businessType: null,
- // 记录规则类型|应用场景
- classify: null,
- // 模块分类 参考字典项:record_rules_report_work_type
- reportWorkType: null,
- // 模板样式
- recordTemplateStyle: null,
- // 执行方式
- isExecuteMethod: 0,
- executeMethodId: null,
- executeMethodName: '',
- produceTaskConfigs: [],
- bigVersion: '',
- versionMark: '',
- smallVersion: '',
- produceTaskId: '',
- produceTaskName: ''
- };
- return {
- dialogTitle: '',
- visible: false,
- formDateBase,
- formData: JSON.parse(JSON.stringify(formDateBase)),
- formRules: {
- name: [{ required: true, message: '请输入名称', trigger: 'blur' }],
- frequencyValue: [
- { required: true, message: '请选择周期', trigger: 'blur' },
- { required: true, message: '请选择周期', trigger: 'change' }
- ],
- frequencyUnit: [
- { required: true, message: '请选择频率单位', trigger: 'change' }
- ],
- classify: [
- { required: true, message: '请选择规则类型', trigger: 'change' }
- ],
- // startDate 启用日期要大于当前时间
- // stopDate 停用时间要大于当前时间并且大于启用日期
- // startDate: [
- // { required: true, message: '请选择启用日期', trigger: 'blur' },
- // { required: true, message: '请选择启用日期', trigger: 'change' },
- // { validator: this.validateStartDate, trigger: 'change' }
- // ],
- // stopDate: [
- // { required: true, message: '请选择停用时间', trigger: 'change' },
- // { validator: this.validateStopDate, trigger: 'change' }
- // ],
- deviceName: [
- { required: true, message: '请输入选择设备', trigger: 'blur' }
- ],
- businessType: [
- { required: true, message: '请选择业务分类', trigger: 'blur' },
- { required: true, message: '请选择业务分类', trigger: 'change' }
- ],
- industryType: [
- { required: true, message: '请选择业行业类别', trigger: 'blur' },
- { required: true, message: '请选择业行业类别', trigger: 'change' }
- ],
- reportWorkType: [
- { required: true, message: '请选择业模块划分', trigger: 'blur' },
- { required: true, message: '请选择业模块划分', trigger: 'change' }
- ],
- classify: [
- { required: true, message: '请选择应用场景', trigger: 'blur' },
- { required: true, message: '请选择应用场景', trigger: 'change' }
- ],
- recordTemplateStyle: [
- { required: true, message: '请选择模板样式', trigger: 'blur' },
- { required: true, message: '请选择模板样式', trigger: 'change' }
- ],
- executeMethodId: [
- { required: true, message: '请选择执行方式', trigger: 'change' },
- { required: true, message: '请选择执行方式', trigger: 'blur' }
- ]
- },
- recordSheet: [], // 记录表
- current: {},
- dataIndex: null,
- showEdit: false,
- btnLoading: false,
- currentRow: null,
- type: '',
- // 产品分类
- productCategory: [],
- loading: false,
- produceTaskCode: '',
- // 执行方式列表
- executeMethodList: [],
- // 1-成品统计,2-物料统计,3-工序统计"
- statisticsType: '1',
- statisticsTypeList: [
- { label: '成品统计', value: '1' },
- { label: '物料统计', value: '2' },
- { label: '工序统计', value: '3' }
- ],
- opSelectOptions: ['+', '-', '*', '/', '%', '(', ')'],
- typeList: [],
- currentIndex: ''
- };
- },
- mounted() {
- this.getByCodeData();
- this.getProductCategory();
- console.log('this.formData 2233', this.formData);
- this.getTypeList();
- },
- methods: {
- open(row, type, title) {
- this.dialogTitle = title;
- this.type = type;
- console.log('type', type, row);
- this.getTypeList();
- if (
- type == 'edit' ||
- type == 'detail' ||
- type == 'change' ||
- type == 'clone'
- ) {
- this.getDetils(row.id);
- }
- // 过程控制临时修改
- if (type == 'processEdit') {
- this.processEditSetValue(row);
- }
- if (type == 'add') {
- this.formData.version = 1;
- // 启用日期 默认为 今天
- this.formData.startDate = new Date();
- // 停用日期 默认为 2099-12-31
- this.formData.stopDate = new Date('2099-12-31 00:00:00');
- console.log('this.typeInfo', this.typeInfo);
- // 类型
- if (this.typeInfo) {
- const node = this.typeInfo;
- const item = node.item || node;
- if (this.businessType) {
- this.formData.businessType = this.businessType + '';
- this.formData.businessName =
- this.businessType == '1' ? '生产' : '质检';
- }
- switch (node.type) {
- case 'industry':
- this.formData.industryType = item.industryType + '';
- break;
- case 'business':
- this.formData.industryType = item.industryType + '';
- this.formData.businessType = item.businessType + '';
- break;
- case 'reportWork':
- this.formData.industryType = item.industryType + '';
- this.formData.businessType = item.businessType + '';
- this.formData.reportWorkType = item.reportWorkType + '';
- break;
- case 'scene':
- this.formData.industryType = item.industryType + '';
- this.formData.businessType = item.businessType + '';
- this.formData.reportWorkType = item.reportWorkType + '';
- this.formData.classify = item.sceneType + '';
- break;
- case 'templateStyle':
- this.formData.industryType = item.industryType + '';
- this.formData.businessType = item.businessType + '';
- this.formData.reportWorkType = item.reportWorkType + '';
- this.formData.classify = item.sceneType + '';
- this.formData.recordTemplateStyle = item.templateStyleType + '';
- break;
- default:
- // 直接赋值所有可用字段(兜底)
- if (item.industryType != null)
- this.formData.industryType = item.industryType + '';
- if (item.businessType != null)
- this.formData.businessType = item.businessType + '';
- if (item.reportWorkType != null)
- this.formData.reportWorkType = item.reportWorkType + '';
- if (item.sceneType != null)
- this.formData.classify = item.sceneType + '';
- if (item.templateStyleType != null)
- this.formData.recordTemplateStyle =
- item.templateStyleType + '';
- break;
- }
- }
- }
- this.visible = true;
- console.log('this.formData', this.formData);
- },
- // 过程控制 修改规则详情
- async processEditSetValue(row) {
- const data = await recordrulesGetById(row.rulesId);
- const info = JSON.parse(JSON.stringify(row));
- data.details = info.produceTaskConfigRuleDetails;
- // 处理详情的 公式 字段
- data.details.forEach((item) => {
- if (item.paramType == 9 && item.formula) {
- // formula格式为[A][+][b][*][C] 拆分 -> ['A','+','b','*','C']
- if (item.formula) {
- const matches = item.formula.match(/\[([^\]]+)\]/g);
- if (matches) {
- this.$set(
- item,
- 'formulaParts',
- matches.map((m) => m.slice(1, -1)).filter(Boolean)
- );
- }
- } else {
- this.$set(item, 'formulaParts', []);
- }
- }
- });
- this.$util.assignObject(this.formData, data);
- this.$nextTick(() => {
- this.$refs.cycleMultipleRef?.setRecordRulesCycleList(
- this.formData.recordRulesCycleList
- );
- });
- this.formData.executeMethodId = info.recordRulesExecuteMethodId;
- this.formData.executeMethodName = info.recordRulesExecuteMethodName;
- this.formData.startDate = new Date(info.startDate || data.startDate);
- this.formData.stopDate = new Date(info.stopDate || data.stopDate);
- this.formData.classify = this.formData.classify + '';
- this.formData.reportWorkType = this.formData.reportWorkType + '';
- this.formData.industryType = this.formData.industryType + '';
- this.formData.businessType = this.formData.businessType + '';
- this.formData.reportWorkType = this.formData.reportWorkType + '';
- this.formData.recordTemplateStyle =
- this.formData.recordTemplateStyle + '';
- console.log('this.formData~~~~', this.formData);
- this.getExecuteMethodList();
- this.loading = false;
- },
- async getDetils(id) {
- this.loading = true;
- try {
- const data = await recordrulesGetById(id);
- this.$util.assignObject(this.formData, data);
- this.$nextTick(() => {
- this.$refs.cycleMultipleRef?.setRecordRulesCycleList(
- this.formData.recordRulesCycleList
- );
- if (this.businessType == 3) {
- this.$refs.experimentationProcess.init(data.tempJson.tempJson);
- }
- });
- this.formData.startDate = new Date(data.startDate);
- this.formData.stopDate = new Date(data.stopDate);
- this.formData.classify = this.formData.classify + '';
- this.formData.industryType = this.formData.industryType + '';
- this.formData.businessType = this.formData.businessType + '';
- this.formData.reportWorkType = this.formData.reportWorkType + '';
- this.formData.recordTemplateStyle =
- this.formData.recordTemplateStyle + '';
- if (this.type == 'change') {
- this.formData.fromId = id;
- this.formData.id = null;
- }
- if (this.type == 'clone') {
- this.formData.fromId = null;
- this.formData.id = null;
- this.formData.produceTaskId = null;
- this.formData.produceTaskName = null;
- this.formData.executeMethodId = null;
- this.formData.executeMethodName = '';
- this.executeMethodList = [];
- // startDate 小于当前日期则取当前日期
- const now = new Date();
- if (this.formData.startDate < now) {
- this.formData.startDate = now;
- }
- } else {
- this.getExecuteMethodList();
- }
- // 处理详情的 公式 字段
- this.formData.details.forEach((item) => {
- if (item.paramType == 9 && item.formula) {
- // formula格式为[A][+][b][*][C] 拆分 -> ['A','+','b','*','C']
- if (item.formula) {
- const matches = item.formula.match(/\[([^\]]+)\]/g);
- if (matches) {
- this.$set(
- item,
- 'formulaParts',
- matches.map((m) => m.slice(1, -1)).filter(Boolean)
- );
- }
- } else {
- this.$set(item, 'formulaParts', []);
- }
- this.$set(item, '_paramSelect', null);
- this.$set(item, '_opSelect', null);
- this.$set(item, '_replaceOrAppend', '');
- }
- });
- this.loading = false;
- } catch (error) {
- console.log(error, 'error');
- this.loading = false;
- }
- },
- async getByCodeData() {
- let res = await getByCode('record_sheet');
- let list = res.data.map((item) => {
- let values = Object.keys(item);
- return {
- value: values[0],
- label: item[values[0]]
- };
- });
- this.recordSheet = list;
- console.log('this.recordSheet', this.recordSheet);
- },
- itemDel(index) {
- this.formData.details.splice(index, 1);
- },
- /* 打开操作手册编辑款 */
- openOperationGuideDialogDialog(row, index) {
- this.$refs.operationGuideDialog.open(row, index);
- },
- handleClose() {
- // 清空表单数据
- this.formData = JSON.parse(JSON.stringify(this.formDateBase));
- this.executeMethodList = [];
- this.$refs['formRef'].resetFields();
- this.visible = false;
- },
- // 保存
- confirm() {
- console.log('this.formData', this.formData);
- // 验证表单规则
- this.$refs.formRef.validate(async (valid) => {
- if (!valid) {
- return false;
- }
- if (this.formData.details.length == 0 && this.businessType != 3) {
- return this.$message.warning('至少选择一条规则项');
- }
- try {
- const valid = this.validateFormula();
- if (!valid) {
- return;
- }
- this.btnLoading = true;
- const body = this.formatBody();
- if (this.type == 'add' || this.type == 'clone') {
- await recordrulesSave(body);
- } else if (this.type == 'change') {
- await recordrulesUpdateVersion(body);
- } else {
- // 编辑
- body.fromId = null;
- await recordrulesUpdate(body);
- }
- this.btnLoading = false;
- this.$message.success('操作成功');
- this.handleClose();
- this.$emit('reload');
- this.$emit('reloadTypeList');
- } catch (error) {
- console.log(error, 'dasda');
- this.btnLoading = false;
- }
- });
- },
- // 保存并发布
- saveAndPublish() {
- // 验证表单规则
- this.$refs.formRef.validate(async (valid) => {
- if (!valid) {
- return false;
- }
- if (this.businessType != 3) {
- if (this.formData.details.length == 0) {
- return this.$message.warning('至少选择一条规则项');
- }
- if (this.formData.reportWorkType == 4) {
- // 生产统计过滤掉非成品统计的明细
- this.formData.details = this.formData.details.filter(
- (i) => i.statisticsType
- );
- }
- // 判断参数类型是否选择
- for (const detail of this.formData.details) {
- if (!detail.paramType) {
- console.log('detail', detail);
- return this.$message.warning('请选择规则明细中的参数类型!');
- }
- }
- }
- try {
- this.btnLoading = true;
- const body = this.formatBody();
- if (this.type != 'saveAndPublish') {
- await recordrulesSaveAndPublish(body);
- } else {
- this.$emit('processSave', body);
- }
- this.btnLoading = false;
- this.$message.success('操作成功');
- this.handleClose();
- this.$emit('reload');
- } catch (error) {
- console.log(error, 'error');
- this.btnLoading = false;
- }
- });
- },
- // 保存或发布时验证公式是否正确
- validateFormula() {
- let invalid = false;
- this.formData.details.forEach((detail) => {
- if (invalid) return; // 已发现无效,后续直接跳过避免重复提示
- if (detail.paramType == 9) {
- const formula = detail.formula;
- if (!formula || !formula.trim()) {
- console.log('formula', formula);
- this.$message.warning('规则明细中计算类型的公式不能为空!');
- invalid = true;
- }
- // 解析公式为 token 列表
- const rawTokens = (formula.match(/\[([^\]]+)\]/g) || [])
- .map((m) => m.slice(1, -1))
- .filter(Boolean);
- if (!rawTokens.length) {
- console.log('rawTokens', rawTokens, formula);
- this.$message.warning('规则明细中计算类型的公式不能为空!');
- invalid = true;
- return;
- }
- const operators = new Set(this.opSelectOptions);
- const availableParams = this.formData.details
- .filter((d) => d !== detail && d.paramType != 9 && d.paramValue)
- .map((d) => d.paramValue);
- const varsSet = new Set();
- let parenBalance = 0;
- let lastWasOperator = true; // 开头不能是普通数字/变量
- let expression = '';
- for (let i = 0; i < rawTokens.length; i++) {
- const t = rawTokens[i];
- if (invalid) break;
- if (operators.has(t)) {
- // 括号
- if (t === '(') {
- parenBalance++;
- lastWasOperator = true;
- } else if (t === ')') {
- parenBalance--;
- if (parenBalance < 0) {
- this.$message.warning('公式括号不匹配');
- invalid = true;
- break;
- }
- lastWasOperator = false;
- } else {
- // 普通运算符不能连续出现
- if (lastWasOperator) {
- this.$message.warning('公式存在连续运算符或位置不合法');
- invalid = true;
- break;
- }
- lastWasOperator = true;
- }
- expression += t;
- } else {
- // 变量
- if (!t.trim()) {
- this.$message.warning('公式中存在空变量');
- invalid = true;
- break;
- }
- // 变量前必须是运算符或者开头或左括号
- if (!lastWasOperator) {
- this.$message.warning('公式中变量之间缺少运算符');
- invalid = true;
- break;
- }
- varsSet.add(t);
- // 校验变量是否存在于其他明细 排除要求生产数量
- if (!availableParams.includes(t) && t != '要求生产数量') {
- this.$message.warning(
- `公式中引用的参数 "${t}" 未在非计算类型的明细中定义`
- );
- invalid = true;
- break;
- }
- // 用顺序数字替换变量
- expression += varsSet.size; // 1,2,3...
- lastWasOperator = false;
- }
- }
- if (invalid) return;
- if (parenBalance !== 0) {
- this.$message.warning('公式括号不匹配');
- invalid = true;
- return;
- }
- if (lastWasOperator) {
- this.$message.warning('公式不能以运算符结尾');
- invalid = true;
- return;
- }
- // 最终表达式字符合法性校验
- if (!/^[0-9+\-*/%() ]+$/.test(expression)) {
- this.$message.warning('公式包含非法字符');
- invalid = true;
- return;
- }
- // 计算测试
- try {
- const result = Function(`"use strict";return (${expression})`)();
- if (Number.isNaN(result) || !isFinite(result)) {
- this.$message.warning('公式计算结果非法');
- invalid = true;
- return;
- }
- } catch (e) {
- this.$message.warning('公式计算失败,请检查语法');
- invalid = true;
- return;
- }
- // 回填拆分后的 parts
- detail.formulaParts = rawTokens;
- }
- });
- if (invalid) {
- return false;
- }
- return true;
- },
- // 数据格式化
- formatBody() {
- this.formData.recordRulesCycleList =
- this.$refs.cycleMultipleRef &&
- this.$refs.cycleMultipleRef.recordRulesCycleList
- .map((i) => {
- // 根据月日时分排序计算权重排序
- let sortNum = 0;
- if (i.month) {
- sortNum += i.month * 60 * 24 * 30;
- }
- if (i.day) {
- sortNum += i.day * 60 * 24;
- }
- if (i.hour) {
- sortNum += i.hour * 60;
- }
- if (i.minute) {
- sortNum += i.minute * 1;
- }
- return { ...i, sortNum };
- })
- .sort((a, b) => a.sortNum - b.sortNum)
- .map((i, index) => {
- return { ...i, sortNum: index + 1 };
- });
- const body = JSON.parse(JSON.stringify(this.formData));
- body.startDate = this.$util.toDateString(
- body.startDate,
- 'yyyy-MM-dd HH:mm:ss'
- );
- body.stopDate = this.$util.toDateString(
- body.stopDate,
- 'yyyy-MM-dd HH:mm:ss'
- );
- if (this.businessType == 3) {
- let tempJson = this.$refs.experimentationProcess.getValue();
- if (tempJson) {
- body.tempJson = {
- tempJson: JSON.stringify(tempJson)
- };
- }
- }
- // details 根据下标添加 sortNum
- body.details = body.details.map((item, index) => {
- return { ...item };
- });
- return body;
- },
- // startDate 启用日期要大于当前时间
- validateStartDate(rule, value, callback) {
- const startDate = this.formData.startDate;
- if (!startDate) {
- return callback(new Error('启用日期不能为空'));
- }
- // 启用日期大于等于今天
- // const today = new Date();
- // today.setHours(0, 0, 0, 0); // 设置为当天的开始时间
- // if (new Date(startDate) < today) {
- // return callback(new Error('启用日期必须大于等于当前日期'));
- // }
- callback();
- },
- // stopDate 停用时间要大于当前时间并且大于启用日期
- validateStopDate(rule, value, callback) {
- const startDate = this.formData.startDate;
- const stopDate = this.formData.stopDate;
- if (
- stopDate &&
- startDate &&
- new Date(stopDate) <= new Date(startDate)
- ) {
- return callback(new Error('停用时间必须大于启用日期'));
- }
- callback();
- },
- // 去选择设备
- selectDeviceId() {
- this.$refs.deviceSelectDialog.open([]);
- },
- // 选择设备回调
- chooseEquipment(data, index, categoryId) {
- console.log('data', data, index, categoryId);
- this.formData.deviceId = data?.id || null;
- this.formData.deviceName = data?.name || '';
- if (this.formData.reportWorkType == 5) {
- this.formData.details = this.formData.details.filter(
- (item) => !item.paramCode
- );
- }
- },
- // 添加
- addRow() {
- // 最大sortNum 值 +1
- let sortNum = 1;
- if (this.formData.details.length > 0) {
- const maxSortNum = Math.max(
- ...this.formData.details.map((item) => item.sortNum || 0)
- );
- sortNum = maxSortNum + 1;
- }
- this.formData.details.push({
- id: new Date().getTime(),
- defaultValue: '',
- maxValue: null,
- minValue: null,
- paramType: null,
- paramValue: null,
- remark: '',
- symbol: null,
- tools: [],
- unitName: null,
- productName: '',
- productCode: '',
- paramCode: '',
- substanceId: '',
- substanceCode: '',
- substanceName: '',
- // 1-成品统计,2-物料统计,3-工序统计"
- statisticsType:
- this.formData.recordTemplateStyle == '4'
- ? this.statisticsType
- : null,
- // 公式
- formula: '',
- _paramSelect: null,
- _opSelect: null,
- _replaceOrAppend: '',
- formulaParts: [],
- sortNum
- });
- console.log('this.formData.details', this.formData.details);
- },
- deleteRow(row) {
- const index = this.formData.details.indexOf(row);
- if (index !== -1) {
- this.formData.details.splice(index, 1);
- }
- },
- handleAdd(row, index, type) {
- this.currentRow = row;
- this.currentIndex = index;
- if (type == 'substanceName') {
- if (!this.formData.deviceId) {
- this.$message.error('请选择主设备!');
- return;
- }
- this.$refs.bindSubstanceRef.open(
- this.formData.deviceId,
- this.formData.deviceName,
- this.formData.deviceCode
- );
- } else {
- this.$refs.toolModalRef.open(row.toolCodes);
- }
- },
- bindSubstanceListOpen() {
- this.currentIndex = 9999;
- this.$refs.bindSubstanceRef.open(
- this.formData.deviceId,
- this.formData.deviceName,
- this.formData.deviceCode
- );
- },
- bindSubstanceSuccess(list) {
- console.log(list, 'list');
- const currentIndex = this.currentIndex;
- list.forEach((item, index) => {
- if (!index && currentIndex != 9999) {
- substanceKey.forEach((key) => {
- this.$set(this.formData.details[currentIndex], key, item[key]);
- });
- this.$set(this.formData.details[currentIndex], 'paramType', 7);
- } else {
- this.formData.details.push({
- id: new Date().getTime(),
- defaultValue: '',
- maxValue: item.maxValue,
- minValue: item.minValue,
- paramType: 7,
- paramValue: item.paramValue,
- remark: '',
- symbol: null,
- tools: [],
- unitName: item.unitName,
- productName: '',
- productCode: '',
- paramCode: item.paramCode,
- iotPointName: item.paramValue,
- iotId: item.iotId,
- substanceId: item.substanceId,
- substanceCode: item.substanceCode,
- substanceName: item.substanceName,
- // 1-成品统计,2-物料统计,3-工序统计"
- statisticsType:
- this.formData.recordTemplateStyle == '4'
- ? this.statisticsType
- : null,
- // 公式
- formula: '',
- _paramSelect: null,
- _opSelect: null,
- _replaceOrAppend: '',
- formulaParts: [],
- sortNum:
- Math.max(
- ...this.formData.details.map((item) => item.sortNum || 0)
- ) + 1
- });
- }
- });
- },
- chooseModal(data) {
- console.log('data', data);
- this.currentRow.tools = data.map((i) => {
- return {
- toolCode: i.code,
- toolName: i.name
- };
- });
- },
- // 规则明细表
- async recordrulesDetailPage(row) {
- const { list } = await recordrulesDetailPage({
- // deptId: row.deptId,
- pageNum: 1,
- rulesId: row.id,
- size: 9999
- });
- console.log('list 数据', list);
- this.formData.details = list;
- },
- // 清空工具
- clearTool(row, index) {
- if (type == 'substanceName') {
- substanceKey.forEach((key) => {
- this.$set(this.formData.details[index], key, '');
- });
- } else {
- row.tools = [];
- }
- },
- // 查询 recordrulesCyclePage
- async recordrulesCyclePage(row) {
- const { list } = await recordrulesCyclePage({
- pageNum: 1,
- size: 9999,
- recordRulesId: row.id,
- orderBy: 'descending'
- });
- console.log('list 周期数据', list);
- this.formData.recordRulesCycleList = list;
- this.$nextTick(() => {
- this.$refs.cycleMultipleRef.setRecordRulesCycleList(list);
- });
- },
- // 去选择产品
- selectProduct(row) {
- this.currentRow = row;
- this.$refs.ProductModalRef.open();
- },
- // 选择产品
- changeProduct(current) {
- console.log('current', current);
- this.currentRow.productName = current.name;
- this.currentRow.productCode = current.code;
- },
- // 选择物品 产品、物料等
- selectChooseModalProduct(row) {
- this.currentRow = row;
- this.$refs.toolModalTowRef.open([], '选择物品');
- },
- chooseModalProduct(current) {
- console.log('current', current);
- this.currentRow.productName = current.name;
- this.currentRow.productCode = current.code;
- this.currentRow.unitName = current.weightUnit;
- console.log('this.currentRow', this.currentRow);
- },
- // 清空产品
- clearProduct(row) {
- row.productName = '';
- row.productCode = '';
- },
- // 获取产品分类
- async getProductCategory() {
- let { data } = await getTreeByPid(9);
- console.log('产品分类', data);
- this.productCategory = data;
- },
- // 选择工序
- openProduceTaskDialog() {
- this.$refs.processModalRef.open();
- },
- // 工序
- processChooseProcess(process) {
- console.log('选择的工序', process);
- this.formData.produceTaskId = process.id;
- this.formData.produceTaskName = process.name;
- this.formData.executeMethodId = null;
- this.formData.executeMethodName = '';
- // 查询工序下的执行方式
- this.getExecuteMethodList();
- },
- clearProductTask() {
- this.formData.produceTaskId = '';
- this.formData.produceTaskName = '';
- this.formData.executeMethodId = null;
- this.formData.executeMethodName = '';
- this.executeMethodList = [];
- },
- // 查询执行方式
- async getExecuteMethodList() {
- if (
- this.formData.produceTaskId == '' &&
- this.formData.reportWorkType == 2
- ) {
- this.executeMethodList = [];
- return;
- }
- const data = await recordrulesexecutemethodPage({
- pageNum: 1,
- size: 9999,
- enable: 1,
- produceTaskId: this.formData.produceTaskId
- });
- this.executeMethodList = data.list;
- // 有执行方式
- if (
- this.executeMethodList.length &&
- this.formData.reportWorkType == 2
- ) {
- this.formData.isExecuteMethod = 1;
- }
- },
- // 过程控制修改 保存
- processEditSave() {
- // 只验证详情内容
- if (this.businessType != 3) {
- if (this.formData.details.length == 0) {
- return this.$message.warning('至少选择一条规则项');
- }
- // 判断参数类型是否选择
- for (const detail of this.formData.details) {
- if (!detail.paramType) {
- return this.$message.warning('请选择规则明细中的参数类型!');
- }
- }
- }
- this.$emit('processSave', this.formatBody());
- this.handleClose();
- },
- // 执行方式改变 同步执行方式名称
- executeMethodIdChange() {
- const selected = this.executeMethodList.find(
- (item) => item.id === this.formData.executeMethodId
- );
- if (selected) {
- this.formData.executeMethodName = selected.name;
- } else {
- this.formData.executeMethodName = '';
- }
- },
- isExecuteMethodChange() {
- if (this.formData.isExecuteMethod == 0) {
- this.formData.executeMethodId = null;
- this.formData.executeMethodName = '';
- }
- },
- classifyChagne() {
- // 生产统计
- if (this.formData.recordTemplateStyle == '4') {
- // 模块分类- 生产统计
- this.formData.reportWorkType = '4';
- // 清空规则明细
- this.formData.details = [];
- // 重置统计类型
- this.statisticsType = '1';
- } else {
- if (this.formData.reportWorkType == '4') {
- this.formData.reportWorkType = '1';
- }
- }
- },
- // 基于详情返回selectOptions
- getSelectOptionsByDetails(statisticsType) {
- let paramTypeOptions = [];
- for (const detail of this.formData.details.filter(
- (i) => i.statisticsType == statisticsType
- )) {
- if (detail.paramType != 9 || !detail.paramType) {
- paramTypeOptions.push({
- value: detail.paramValue,
- label: detail.paramValue
- });
- }
- }
- // 过滤空值
- paramTypeOptions = paramTypeOptions.filter((i) => i.value);
- // 追加一个 (要求生产数量)
- paramTypeOptions.push({
- value: '要求生产数量',
- label: '要求生产数量'
- });
- return paramTypeOptions;
- },
- paramSelectChange(val, row) {
- if (!val) return;
- row.formulaParts = row.formulaParts || [];
- if (row.activeIndex != undefined) {
- if (!row._replaceOrAppend || row._replaceOrAppend === 'replace') {
- row.formulaParts.splice(row.activeIndex, 1, val);
- } else if (row._replaceOrAppend === 'append') {
- row.formulaParts.splice(row.activeIndex + 1, 0, val);
- // 追加后activeIndex后移一位
- this.$set(row, 'activeIndex', row.activeIndex + 1);
- }
- // row.activeIndex = undefined;
- } else {
- row.formulaParts.push(val);
- }
- row.formula = row.formulaParts.map((p) => `[${p}]`).join('');
- row._paramSelect = null;
- },
- opSelectChange(val, row) {
- if (!val) return;
- row.formulaParts = row.formulaParts || [];
- if (row.activeIndex != undefined) {
- if (!row._replaceOrAppend || row._replaceOrAppend === 'replace') {
- row.formulaParts.splice(row.activeIndex, 1, val);
- } else if (row._replaceOrAppend === 'append') {
- row.formulaParts.splice(row.activeIndex + 1, 0, val);
- // 追加后activeIndex后移一位
- this.$set(row, 'activeIndex', row.activeIndex + 1);
- }
- // row.activeIndex = undefined;
- } else {
- row.formulaParts.push(val);
- }
- row.formula = row.formulaParts.map((p) => `[${p}]`).join('');
- row._opSelect = null;
- },
- tagItemDelete(index, row) {
- if (this.type == 'detail') return;
- row.formulaParts.splice(index, 1);
- row.formula = row.formulaParts.map((p) => `[${p}]`).join('');
- },
- formulaPartsTagClick(index, row) {
- if (this.type == 'detail') return;
- if (!row._replaceOrAppend) {
- // 默认追加
- row._replaceOrAppend = 'append';
- }
- if (row.activeIndex && row.activeIndex === index) {
- this.$set(row, 'activeIndex', undefined);
- } else {
- this.$set(row, 'activeIndex', index);
- }
- },
- // 类型变化
- paramTypeChange(row) {
- if (row.pageType != 9) {
- // 清空
- row.formulaParts = [];
- row.formula = '';
- }
- },
- // 类型列表
- async getTypeList() {
- const { list = [] } = await recordrulesTypePage({
- pageNum: 1,
- size: 99999
- });
- this.typeList = list;
- console.log('this.typeList', this.typeList);
- },
- industryTypeChange() {
- this.formData.businessType = '';
- this.formData.reportWorkType = '';
- this.formData.classify = '';
- this.formData.recordTemplateStyle = '';
- },
- businessTypeChange() {
- this.formData.reportWorkType = '';
- this.formData.classify = '';
- this.formData.recordTemplateStyle = '';
- },
- reportWorkTypeChange() {
- this.formData.classify = '';
- this.formData.recordTemplateStyle = '';
- },
- classifyChange() {
- this.formData.recordTemplateStyle = '';
- }
- }
- };
- </script>
- <style scoped lang="scss">
- .operationGuide_box {
- width: 100%;
- height: 48px;
- display: flex;
- overflow: hidden;
- cursor: pointer;
- box-sizing: border-box;
- padding: 5px 10px;
- .left_content {
- width: 50%;
- padding: 10px;
- box-sizing: border-box;
- border: 1px solid #c0c4cc;
- border-radius: 10px;
- margin-right: 10px;
- overflow-y: auto;
- }
- .right_content {
- flex: 1;
- padding: 10px;
- box-sizing: border-box;
- border: 1px solid #c0c4cc;
- border-radius: 10px;
- overflow-y: auto;
- }
- }
- ::v--deep .table_list {
- .el-form-item {
- .el-form-item__content {
- margin-left: 0;
- }
- }
- }
- .formula-builder {
- .formula-builder__selects {
- margin-bottom: 6px;
- display: flex;
- flex-shrink: 0;
- }
- }
- :deep(.el-dialog:not(.ele-dialog-form) .el-dialog__body .el-form) {
- .el-form-item:last-child {
- margin-bottom: 22px;
- }
- }
- </style>
|