permitAdd.vue 75 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381
  1. <template>
  2. <ele-modal
  3. :title="dialogTitle"
  4. :visible.sync="visible"
  5. :before-close="handleClose"
  6. :close-on-click-modal="false"
  7. :close-on-press-escape="false"
  8. width="80%"
  9. :maxable="true"
  10. append-to-body
  11. destroy-on-close
  12. >
  13. <el-form
  14. label-width="115px"
  15. :model="formData"
  16. :rules="formRules"
  17. ref="formRef"
  18. v-loading="loading"
  19. :disabled="type == 'detail'"
  20. >
  21. <el-row>
  22. <el-col :span="8">
  23. <el-form-item label="行业类别" prop="industryType">
  24. <el-select
  25. v-model="formData.industryType"
  26. placeholder="请选择行业类别"
  27. style="width: 100%"
  28. @change="industryTypeChange"
  29. >
  30. <el-option
  31. v-for="item in industryTypeList"
  32. :key="item.value"
  33. :label="item.label"
  34. :value="item.value"
  35. />
  36. </el-select>
  37. </el-form-item>
  38. </el-col>
  39. <el-col :span="8">
  40. <el-form-item label="业务分类" prop="businessType">
  41. <el-select
  42. v-model="formData.businessType"
  43. placeholder="请选择业务分类"
  44. style="width: 100%"
  45. @change="businessTypeChange"
  46. :disabled="!!businessType"
  47. >
  48. <el-option
  49. v-for="item in businessTypeList"
  50. :key="item.value"
  51. :label="item.label"
  52. :value="item.value"
  53. />
  54. </el-select>
  55. </el-form-item>
  56. </el-col>
  57. <el-col :span="8">
  58. <el-form-item label="模块划分" prop="reportWorkType">
  59. <el-select
  60. v-model="formData.reportWorkType"
  61. placeholder="请选择模块划分"
  62. style="width: 100%"
  63. @change="reportWorkTypeChange"
  64. >
  65. <el-option
  66. v-for="item in reportWorkTypeList"
  67. :key="item.value"
  68. :label="item.label"
  69. :value="item.value"
  70. />
  71. </el-select>
  72. </el-form-item>
  73. </el-col>
  74. <el-col :span="8">
  75. <el-form-item label="应用场景" prop="classify">
  76. <el-select
  77. v-model="formData.classify"
  78. placeholder="请选择应用场景"
  79. style="width: 100%"
  80. @change="classifyChange"
  81. >
  82. <el-option
  83. v-for="item in classifyList"
  84. :key="item.value"
  85. :label="item.label"
  86. :value="item.value"
  87. />
  88. </el-select>
  89. </el-form-item>
  90. </el-col>
  91. <el-col :span="8">
  92. <el-form-item label="模板样式" prop="recordTemplateStyle">
  93. <el-select
  94. v-model="formData.recordTemplateStyle"
  95. placeholder="请选择模板样式"
  96. style="width: 100%"
  97. >
  98. <el-option
  99. v-for="item in recordTemplateStyleList"
  100. :key="item.value"
  101. :label="item.label"
  102. :value="item.value"
  103. />
  104. </el-select>
  105. </el-form-item>
  106. </el-col>
  107. <el-col :span="8">
  108. <el-form-item label="编码" prop="code">
  109. <el-input
  110. v-model="formData.code"
  111. :disabled="true"
  112. placeholder="系统自动生成"
  113. ></el-input>
  114. </el-form-item>
  115. </el-col>
  116. <el-col :span="8">
  117. <el-form-item label="版本">
  118. <el-input
  119. :value="versionText"
  120. disabled
  121. placeholder="系统自动生成"
  122. ></el-input>
  123. </el-form-item>
  124. </el-col>
  125. <el-col :span="8">
  126. <el-form-item label="名称" prop="name">
  127. <el-input
  128. v-model="formData.name"
  129. placeholder="请输入"
  130. :disabled="type == 'processEdit'"
  131. ></el-input>
  132. </el-form-item>
  133. </el-col>
  134. <el-col :span="8">
  135. <el-form-item
  136. label="启用日期"
  137. prop="startDate"
  138. :rules="
  139. businessType != 3 && formData.reportWorkType != 6
  140. ? [
  141. {
  142. required: true,
  143. message: '请选择启用日期',
  144. trigger: 'blur'
  145. },
  146. {
  147. required: true,
  148. message: '请选择启用日期',
  149. trigger: 'change'
  150. },
  151. { validator: validateStartDate, trigger: 'change' }
  152. ]
  153. : []
  154. "
  155. >
  156. <el-date-picker
  157. v-model="formData.startDate"
  158. type="date"
  159. placeholder="请选择启用日期"
  160. style="width: 100%"
  161. :picker-options="{
  162. disabledDate: (time) =>
  163. time.getTime() < new Date(new Date().toDateString()).getTime()
  164. }"
  165. :disabled="type == 'processEdit'"
  166. />
  167. </el-form-item>
  168. </el-col>
  169. <el-col :span="8">
  170. <el-form-item
  171. label="停用日期"
  172. prop="stopDate"
  173. :rules="
  174. businessType != 3 && formData.reportWorkType != 6
  175. ? [
  176. {
  177. required: true,
  178. message: '请选择停用时间',
  179. trigger: 'change'
  180. },
  181. { validator: validateStopDate, trigger: 'change' }
  182. ]
  183. : []
  184. "
  185. >
  186. <el-date-picker
  187. v-model="formData.stopDate"
  188. type="date"
  189. placeholder="请选择停用日期"
  190. style="width: 100%"
  191. :disabled="type == 'processEdit'"
  192. />
  193. </el-form-item>
  194. </el-col>
  195. <!-- <el-col :span="8">
  196. <el-form-item label="物联设备" prop="stopDate">
  197. </el-form-item>
  198. </el-col> -->
  199. <el-col
  200. v-if="
  201. (formData.recordTemplateStyle == '2' && this.businessType != 3) ||
  202. formData.reportWorkType == 5
  203. "
  204. :span="8"
  205. >
  206. <el-form-item label="关联设备" prop="deviceName" required>
  207. <el-input
  208. v-model="formData.deviceName"
  209. placeholder="请选择设备"
  210. :readonly="true"
  211. >
  212. <template #append>
  213. <el-button @click="selectDeviceId">选择设备</el-button>
  214. </template>
  215. </el-input>
  216. </el-form-item>
  217. </el-col>
  218. <el-col
  219. v-if="
  220. (formData.recordTemplateStyle == '2' && this.businessType != 3) ||
  221. formData.reportWorkType == 5
  222. "
  223. :span="8"
  224. >
  225. <el-form-item label="设备编号" prop="codeNumber">
  226. <el-input v-model="formData.codeNumber" :disabled="true">
  227. </el-input>
  228. </el-form-item>
  229. </el-col>
  230. <el-col
  231. v-if="formData.reportWorkType == 2 && this.businessType != 3"
  232. :span="8"
  233. >
  234. <el-form-item label="关联工序">
  235. <el-input
  236. v-model="formData.produceTaskName"
  237. @click.native="openProduceTaskDialog"
  238. readonly
  239. placeholder="关联工序"
  240. clearable
  241. :disabled="type == 'processEdit'"
  242. >
  243. <i
  244. v-if="formData.produceTaskName"
  245. slot="suffix"
  246. class="el-input__icon el-icon-close"
  247. size="24"
  248. @click.stop="clearProductTask"
  249. ></i>
  250. </el-input>
  251. </el-form-item>
  252. </el-col>
  253. <el-col
  254. v-if="formData.reportWorkType == 2 && this.businessType != 3"
  255. :span="8"
  256. >
  257. <el-form-item label="是否有执行方式" label-width="130px">
  258. <el-radio-group
  259. v-model="formData.isExecuteMethod"
  260. @change="isExecuteMethodChange"
  261. >
  262. <el-radio :label="1">是</el-radio>
  263. <el-radio :label="0">否</el-radio>
  264. </el-radio-group>
  265. </el-form-item>
  266. </el-col>
  267. <el-col
  268. v-if="
  269. formData.isExecuteMethod == 1 &&
  270. formData.reportWorkType == 2 &&
  271. this.businessType != 3
  272. "
  273. :span="8"
  274. >
  275. <el-form-item label="执行方式" required prop="executeMethodId">
  276. <el-select
  277. v-model="formData.executeMethodId"
  278. filterable
  279. placeholder="请选择"
  280. style="width: 100%"
  281. @change="executeMethodIdChange"
  282. >
  283. <el-option
  284. v-for="item in executeMethodList"
  285. :key="item.id"
  286. :label="item.name"
  287. :value="item.id"
  288. >
  289. </el-option>
  290. </el-select>
  291. </el-form-item>
  292. </el-col>
  293. </el-row>
  294. <el-row v-if="businessType != 3 && formData.reportWorkType != 6">
  295. <el-col :span="24">
  296. <el-form-item label="周期" prop="frequencyValue" required>
  297. <rule-cycle
  298. ref="cycleMultipleRef"
  299. :formData="formData"
  300. :pageType="type"
  301. :isBindPlan="type == 'processEdit'"
  302. />
  303. </el-form-item>
  304. </el-col>
  305. </el-row>
  306. <header-title
  307. title="规则明细"
  308. v-if="businessType != 3 && formData.reportWorkType != 6"
  309. >
  310. </header-title>
  311. <el-tabs
  312. v-if="formData.recordTemplateStyle == '4' && businessType != 3"
  313. v-model="statisticsType"
  314. type="card"
  315. >
  316. <el-tab-pane
  317. v-for="i in statisticsTypeList"
  318. :label="i.label"
  319. :name="i.value"
  320. :key="i.value"
  321. >
  322. </el-tab-pane>
  323. </el-tabs>
  324. <ele-pro-table
  325. v-if="businessType != 3 && formData.reportWorkType != 6"
  326. ref="table"
  327. :columns="bankColumns"
  328. :datasource="detialsDatasource"
  329. :need-page="false"
  330. row-key="id"
  331. class="table_list"
  332. :cache-key="cacheKeyUrl"
  333. >
  334. <template v-slot:toolbar>
  335. <div style="display: flex; align-items: center; gap: 10px">
  336. <el-button
  337. type="primary"
  338. icon="el-icon-plus"
  339. class="ele-btn-icon"
  340. @click="addRow"
  341. >
  342. 新建
  343. </el-button>
  344. <el-button
  345. type="primary"
  346. icon="el-icon-plus"
  347. class="ele-btn-icon"
  348. @click="bindSubstanceListOpen"
  349. v-if="formData.reportWorkType == 5"
  350. >
  351. 添加物联参数
  352. </el-button>
  353. </div>
  354. </template>
  355. <template v-slot:sortNum="{ row }">
  356. <el-input-number
  357. style="width: 80px"
  358. v-model.number="row.sortNum"
  359. placeholder="请输入排序"
  360. size="mini"
  361. type="number"
  362. :min="1"
  363. controls-position="right"
  364. ></el-input-number>
  365. </template>
  366. <template v-slot:paramType="{ row }">
  367. <el-select
  368. v-model="row.paramType"
  369. placeholder="请选择参数类型"
  370. size="mini"
  371. @change="paramTypeChange(row)"
  372. :disabled="!!row.paramCode"
  373. >
  374. <el-option label="数值" :value="1" />
  375. <el-option label="选择" :value="2" />
  376. <el-option label="上下限" :value="3" />
  377. <el-option label="规格" :value="4" />
  378. <el-option label="时间" :value="5" />
  379. <el-option label="范围" :value="6" />
  380. <el-option label="文本" :value="7" />
  381. <!-- <el-option label="枚举" :value="8" /> -->
  382. <el-option label="计算" :value="9" />
  383. </el-select>
  384. </template>
  385. <template v-slot:paramValue="{ row }">
  386. <!-- 根据参数类型渲染不同的输入组件 -->
  387. <el-link
  388. v-if="formData.recordTemplateStyle == '3'"
  389. :underline="false"
  390. style="cursor: pointer"
  391. >
  392. <div class="ele-cell">
  393. <div @click="selectChooseModalProduct(row)">
  394. {{ row.productName ? row.productName : '请选择产品' }}
  395. </div>
  396. <i
  397. v-if="row.tools.length == 0"
  398. class="el-icon-arrow-down"
  399. @click="selectChooseModalProduct(row)"
  400. ></i>
  401. <i v-else class="el-icon-close" @click="clearProduct(row)"></i>
  402. </div>
  403. </el-link>
  404. <el-input
  405. v-else
  406. v-model="row.paramValue"
  407. placeholder="请输入参数内容"
  408. size="mini"
  409. type="textarea"
  410. rows="1"
  411. autosize
  412. ></el-input>
  413. </template>
  414. <template v-slot:supplierName="{ row, $index }">
  415. {{ row.supplierName }}
  416. <el-button
  417. type="primary"
  418. icon="el-icon-plus"
  419. class="ele-btn-icon"
  420. @click="addSupplier(row, $index)"
  421. >
  422. 选择供应商
  423. </el-button>
  424. </template>
  425. <template v-slot:formula="{ row }">
  426. <div v-if="row.paramType == 9" class="formula-builder">
  427. <div class="formula-builder__selects">
  428. <!-- 选择参数:从已填的非计算参数内容里取 -->
  429. <el-select
  430. v-model="row._paramSelect"
  431. placeholder="选择参数"
  432. size="mini"
  433. style="width: 100px; margin-right: 8px; flex-shrink: 0"
  434. @change="paramSelectChange($event, row)"
  435. >
  436. <el-option
  437. v-for="item in getSelectOptionsByDetails(row.statisticsType)"
  438. :key="item.value"
  439. :label="item.label"
  440. :value="item.value"
  441. />
  442. </el-select>
  443. <!-- 选择运算符 -->
  444. <el-select
  445. v-model="row._opSelect"
  446. :key="row._opSelect + '_opSelect'"
  447. placeholder="选择符号"
  448. size="mini"
  449. style="width: 100px; flex-shrink: 0"
  450. @change="opSelectChange($event, row)"
  451. >
  452. <el-option
  453. v-for="op in opSelectOptions"
  454. :key="op"
  455. :label="op"
  456. :value="op"
  457. />
  458. </el-select>
  459. <!-- 替换或者追加 -->
  460. <el-select
  461. v-if="row.activeIndex != undefined"
  462. v-model="row._replaceOrAppend"
  463. :key="row._replaceOrAppend + 'row._replaceOrAppend'"
  464. placeholder="选择"
  465. size="mini"
  466. style="width: 80px; margin-left: 8px; flex-shrink: 0"
  467. >
  468. <el-option key="append" label="追加" value="append" />
  469. <el-option key="replace" label="替换" value="replace" />
  470. </el-select>
  471. </div>
  472. <!-- 已组装公式标签展示 -->
  473. <div
  474. v-if="row.formulaParts && row.formulaParts.length"
  475. style="display: inline-flex; flex-wrap: wrap; max-width: 100%"
  476. >
  477. <el-tag
  478. v-for="(p, index) in row.formulaParts"
  479. :key="index"
  480. size="mini"
  481. closable
  482. :type="row.activeIndex === index ? 'primary' : 'info'"
  483. @click="formulaPartsTagClick(index, row)"
  484. @close="tagItemDelete(index, row)"
  485. >
  486. {{ p }}
  487. </el-tag>
  488. </div>
  489. <!-- 公式字符串展示(只读) -->
  490. <el-input
  491. v-if="row.formulaParts && row.formulaParts.length"
  492. :value="row.formulaParts.join('')"
  493. size="mini"
  494. type="textarea"
  495. disabled
  496. placeholder="公式"
  497. style="margin-top: 6px"
  498. />
  499. </div>
  500. </template>
  501. <template v-slot:defaultValue="{ row }">
  502. <el-row>
  503. <el-col :span="12">
  504. <!-- <el-select
  505. v-if="row.paramType != 7"
  506. v-model="row.symbol"
  507. placeholder="请选择"
  508. size="mini"
  509. >
  510. <el-option label=">" value=">"> </el-option>
  511. <el-option label="<" value="<"> </el-option>
  512. <el-option label="!=" value="!="> </el-option>
  513. <el-option label=">=" value=">="> </el-option>
  514. <el-option label="<=" value="<="> </el-option>
  515. <el-option label="~~" value="~~"> </el-option>
  516. <el-option label="+-" value="+-"> </el-option>
  517. <el-option label="......" value="......"> </el-option>
  518. </el-select> -->
  519. <DictSelection
  520. v-if="row.paramType != 7"
  521. clearable
  522. dictName="数学字符"
  523. v-model="row.symbol"
  524. placeholder="请选择逻辑"
  525. size="mini"
  526. ></DictSelection>
  527. </el-col>
  528. <el-col :span="row.paramType != 7 ? 12 : 24">
  529. <el-input
  530. v-model="row.defaultValue"
  531. placeholder="请输入默认值"
  532. size="mini"
  533. ></el-input>
  534. </el-col>
  535. </el-row>
  536. </template>
  537. <template v-slot:maxValue="{ row }">
  538. <el-input
  539. v-if="row.paramType == 3 || row.paramType == 6"
  540. v-model="row.maxValue"
  541. placeholder="请输入参数上限"
  542. size="mini"
  543. ></el-input>
  544. <span v-else-if="row.paramType == 7 && row.paramCode">{{
  545. row.maxValue
  546. }}</span>
  547. </template>
  548. <template v-slot:minValue="{ row }">
  549. <el-input
  550. v-if="row.paramType == 3 || row.paramType == 6"
  551. v-model="row.minValue"
  552. placeholder="请输入参数下限"
  553. size="mini"
  554. ></el-input>
  555. <span v-else-if="row.paramType == 7 && row.paramCode">{{
  556. row.minValue
  557. }}</span>
  558. </template>
  559. <template v-slot:unitName="{ row }">
  560. <!-- <el-input
  561. v-model="row.unitName"
  562. placeholder="请输入参数单位"
  563. size="mini"
  564. ></el-input> -->
  565. <DictSelection
  566. v-if="row.paramType != 7"
  567. dictName="工艺参数单位"
  568. clearable
  569. filterable
  570. v-model="row.unitName"
  571. size="mini"
  572. >
  573. </DictSelection>
  574. <span v-else-if="row.paramType == 7 && row.paramCode">{{
  575. row.unitName
  576. }}</span>
  577. </template>
  578. <template v-slot:toolName="{ row, $index }">
  579. <el-link :underline="false" style="cursor: pointer">
  580. <div class="ele-cell">
  581. <div @click="handleAdd(row, '', 'toolName')">
  582. {{
  583. row.tools && row.tools.length > 0
  584. ? row.tools.map((i) => i.toolName).join(',')
  585. : '请选择'
  586. }}
  587. </div>
  588. <i
  589. v-if="row.tools.length == 0"
  590. class="el-icon-arrow-down"
  591. @click="handleAdd(row, '', 'toolName')"
  592. ></i>
  593. <i
  594. v-else
  595. class="el-icon-close"
  596. @click="clearTool(row, '', 'toolName')"
  597. ></i>
  598. </div>
  599. </el-link>
  600. </template>
  601. <template v-slot:substanceName="{ row, $index }">
  602. <el-link :underline="false" style="cursor: pointer">
  603. <div class="ele-cell">
  604. <div @click="handleAdd(row, $index, 'substanceName')">
  605. {{ row.substanceName || '请选择' }}
  606. </div>
  607. <i
  608. v-if="!row.substanceName"
  609. class="el-icon-arrow-down"
  610. @click="handleAdd(row, $index, 'substanceName')"
  611. ></i>
  612. <i
  613. v-else
  614. class="el-icon-close"
  615. @click="clearTool(row, $index, 'substanceName')"
  616. ></i>
  617. </div>
  618. </el-link>
  619. </template>
  620. <template v-slot:iotPointName="{ row, $index }">
  621. <el-link :underline="false" style="cursor: pointer">
  622. <div class="ele-cell">
  623. <div @click="handleAdd(row, $index, 'iotPointName')">
  624. {{ row.iotPointName || '请选择' }}
  625. </div>
  626. <i
  627. v-if="!row.iotPointName"
  628. class="el-icon-arrow-down"
  629. @click="handleAdd(row, $index, 'iotPointName')"
  630. ></i>
  631. </div>
  632. </el-link>
  633. </template>
  634. <template v-slot:toolCodes="{ row }">
  635. <el-input
  636. :value="
  637. row.tools && row.tools.length > 0
  638. ? row.tools.map((i) => i.toolCode).join(',')
  639. : ''
  640. "
  641. placeholder="自动带出"
  642. disabled
  643. size="mini"
  644. ></el-input>
  645. </template>
  646. <template v-slot:substanceCode="{ row }">
  647. <el-input
  648. :value="row.substanceCode"
  649. placeholder="自动带出"
  650. disabled
  651. size="mini"
  652. ></el-input>
  653. </template>
  654. <template v-slot:remark="{ row }">
  655. <el-input
  656. v-model="row.remark"
  657. placeholder="请输入"
  658. size="mini"
  659. ></el-input>
  660. </template>
  661. <template v-slot:action="{ row }">
  662. <el-link
  663. v-if="type != 'detail'"
  664. type="danger"
  665. :underline="false"
  666. icon="el-icon-delete"
  667. @click="deleteRow(row)"
  668. >
  669. 删除
  670. </el-link>
  671. </template>
  672. </ele-pro-table>
  673. <header-title
  674. :title="
  675. formData.reportWorkType == 1
  676. ? '实验过程'
  677. : formData.reportWorkType == 2
  678. ? '实验记录'
  679. : ''
  680. "
  681. v-if="businessType == 3"
  682. >
  683. </header-title>
  684. <header-title
  685. title="作业票模板
  686. "
  687. v-if="businessType == 1 && formData.reportWorkType == 6"
  688. >
  689. </header-title>
  690. <experimentationProcess
  691. :edit="type != 'detail'"
  692. :readonly="type == 'detail'"
  693. v-if="businessType == 3"
  694. ref="experimentationProcess"
  695. ></experimentationProcess>
  696. <experimentationProcessNew
  697. :edit="type != 'detail'"
  698. ref="experimentationProcess"
  699. :readonly="type == 'detail'"
  700. v-if="businessType == 1 && formData.reportWorkType == 6"
  701. ></experimentationProcessNew>
  702. </el-form>
  703. <template v-slot:footer>
  704. <el-button
  705. v-if="type != 'detail' && type != 'processEdit'"
  706. :loading="btnLoading"
  707. type="primary"
  708. @click="saveAndPublish"
  709. >
  710. 保存并发布
  711. </el-button>
  712. <el-button
  713. v-if="type != 'detail' && type != 'processEdit'"
  714. :loading="btnLoading"
  715. type="primary"
  716. @click="confirm"
  717. >
  718. 保存
  719. </el-button>
  720. <el-button
  721. v-if="type == 'processEdit'"
  722. :loading="btnLoading"
  723. type="primary"
  724. @click="processEditSave"
  725. >
  726. 保存
  727. </el-button>
  728. <el-button :loading="btnLoading" @click="handleClose">取消</el-button>
  729. </template>
  730. <toolModal ref="toolModalRef" @chooseModal="chooseModal" />
  731. <toolModal
  732. ref="toolModalTowRef"
  733. @chooseModal="chooseModalProduct"
  734. :multiple="false"
  735. />
  736. <MaterialAdd
  737. ref="deviceSelectDialog"
  738. selectType="single"
  739. @chooseEquipment="chooseEquipment"
  740. :multiple="false"
  741. />
  742. <bindSubstanceList
  743. ref="bindSubstanceRef"
  744. @bindSubstanceSuccess="bindSubstanceSuccess"
  745. ></bindSubstanceList>
  746. <ProductModal
  747. ref="ProductModalRef"
  748. @changeProduct="changeProduct"
  749. ></ProductModal>
  750. <processModal
  751. ref="processModalRef"
  752. @chooseProcess="processChooseProcess"
  753. ></processModal>
  754. <!-- <vendorDialog
  755. ref="supplierSelectionRef"
  756. @success="confirmStaffSelection1"
  757. :isAll="true"
  758. ></vendorDialog> -->
  759. </ele-modal>
  760. </template>
  761. <script>
  762. //设备初始化字段
  763. const substanceKey = [
  764. 'substanceCode',
  765. 'substanceId',
  766. 'substanceName',
  767. 'paramCode',
  768. 'paramValue',
  769. 'maxValue',
  770. 'minValue',
  771. 'unitName',
  772. 'iotId',
  773. 'iotPointName'
  774. ];
  775. import { getByCode } from '@/api/system/dictionary-data';
  776. // import RuleCycle from '../../matterRules/components/rule-cycle.vue';
  777. import RuleCycle from './rule-cycle.vue';
  778. import OperationGuideDialog from '@/views/rulesManagement/matterRules/components/operationGuideDialog.vue';
  779. import Details from './details.vue';
  780. import dictMixins from '@/mixins/dictMixins';
  781. import toolModal from './toolModal.vue';
  782. import bindSubstanceList from './bindSubstanceList.vue';
  783. import MaterialAdd from '../../components/MaterialAdd.vue';
  784. // import vendorDialog from '@/views/factoryModel/qualificationManagement/components/vendorDialog.vue';
  785. import {
  786. recordrulesSave,
  787. recordrulesDetailPage,
  788. recordrulesUpdate,
  789. recordrulesPublish,
  790. recordrulesSaveAndPublish,
  791. recordrulesUpdateVersion,
  792. recordrulesCyclePage,
  793. recordrulesGetById,
  794. recordrulesTypePage
  795. } from '@/api/recordrules/index';
  796. import ProductModal from '@/components/selectProduct/ProductModal.vue';
  797. import { getTreeByPid } from '@/api/classifyManage';
  798. import processModal from './processModal.vue';
  799. import experimentationProcess from './experimentationProcess.vue';
  800. import experimentationProcessNew from './experimentationProcessNew.vue';
  801. import ProductModalCorrelation from './ProductModal.vue';
  802. import { recordrulesexecutemethodPage } from '@/api/recordrulesexecutemethod/index';
  803. import { businessTypeList } from '@/views/regulationManagement/components/util';
  804. export default {
  805. mixins: [dictMixins],
  806. components: {
  807. OperationGuideDialog,
  808. RuleCycle,
  809. Details,
  810. ProductModal,
  811. MaterialAdd,
  812. toolModal,
  813. processModal,
  814. ProductModalCorrelation,
  815. experimentationProcess,
  816. bindSubstanceList,
  817. experimentationProcessNew
  818. // vendorDialog
  819. },
  820. props: {
  821. typeInfo: {
  822. type: Object,
  823. default: () => null
  824. },
  825. businessType: ''
  826. },
  827. computed: {
  828. bankColumns() {
  829. let list = [
  830. {
  831. width: 110,
  832. type: 'index',
  833. columnKey: 'index',
  834. align: 'center',
  835. label: '序号'
  836. },
  837. {
  838. prop: 'sortNum',
  839. label: '排序',
  840. align: 'center',
  841. slot: 'sortNum',
  842. minWidth: 110
  843. },
  844. {
  845. prop: 'paramType',
  846. label: '参数类型',
  847. align: 'center',
  848. slot: 'paramType',
  849. minWidth: 110
  850. },
  851. {
  852. prop: 'paramValue',
  853. label: '参数内容',
  854. align: 'center',
  855. slot: 'paramValue',
  856. minWidth: 261
  857. },
  858. {
  859. prop: 'iotPointName',
  860. slot: 'iotPointName',
  861. label: '物联点位',
  862. align: 'center',
  863. minWidth: 150
  864. },
  865. {
  866. prop: 'formula',
  867. label: '计算公式',
  868. align: 'center',
  869. slot: 'formula',
  870. minWidth: 300
  871. },
  872. {
  873. prop: 'defaultValue',
  874. label: '默认值',
  875. align: 'center',
  876. slot: 'defaultValue',
  877. minWidth: 150
  878. },
  879. {
  880. prop: 'maxValue',
  881. label: '参数上限',
  882. align: 'center',
  883. slot: 'maxValue',
  884. minWidth: 110
  885. },
  886. {
  887. prop: 'minValue',
  888. label: '参数下限',
  889. align: 'center',
  890. slot: 'minValue',
  891. minWidth: 110
  892. },
  893. {
  894. prop: 'unitName',
  895. label: '参数单位',
  896. align: 'center',
  897. slot: 'unitName',
  898. minWidth: 110
  899. },
  900. {
  901. prop: 'substanceName',
  902. label: '设备名称',
  903. align: 'center',
  904. slot: 'substanceName',
  905. minWidth: 110
  906. },
  907. {
  908. prop: 'substanceCode',
  909. label: '设备编码',
  910. align: 'center',
  911. slot: 'substanceCode',
  912. minWidth: 110
  913. },
  914. {
  915. prop: 'toolName',
  916. label: '工具名称',
  917. align: 'center',
  918. slot: 'toolName',
  919. minWidth: 110
  920. },
  921. {
  922. prop: 'toolCodes',
  923. label: '工具编码',
  924. align: 'center',
  925. slot: 'toolCodes',
  926. minWidth: 110
  927. },
  928. {
  929. prop: 'remark',
  930. label: '备注',
  931. align: 'center',
  932. slot: 'remark',
  933. minWidth: 110
  934. },
  935. {
  936. columnKey: 'action',
  937. label: '操作',
  938. width: 110,
  939. align: 'center',
  940. resizable: false,
  941. slot: 'action',
  942. fixed: 'right'
  943. }
  944. ];
  945. if (this.formData.recordTemplateStyle != '4') {
  946. // 过滤掉 计算公式 列
  947. list = list.filter((i) => i.prop != 'formula');
  948. }
  949. // 只有生产管控类才显示设备信息
  950. if (this.formData.reportWorkType != 5) {
  951. list = list.filter(
  952. (i) => !['substanceName', 'substanceCode'].includes(i.prop)
  953. );
  954. }
  955. return list;
  956. },
  957. versionText() {
  958. if (this.type == 'change') {
  959. return '系统自动生成';
  960. }
  961. return (
  962. this.formData.bigVersion +
  963. this.formData.versionMark +
  964. this.formData.smallVersion
  965. );
  966. },
  967. productColumns() {
  968. return [
  969. {
  970. columnKey: 'index',
  971. type: 'index',
  972. width: 45,
  973. align: 'center',
  974. reserveSelection: true
  975. },
  976. {
  977. prop: 'code',
  978. label: '产品编码'
  979. },
  980. {
  981. prop: 'name',
  982. label: '产品名称',
  983. showOverflowTooltip: true
  984. },
  985. {
  986. prop: 'brandNum',
  987. label: '牌号'
  988. },
  989. {
  990. prop: 'modelType',
  991. label: '型号'
  992. },
  993. {
  994. prop: 'specification',
  995. label: '规格'
  996. },
  997. {
  998. prop: 'measuringUnit',
  999. label: '计量单位'
  1000. },
  1001. {
  1002. prop: 'packingUnit',
  1003. label: '包装单位'
  1004. },
  1005. {
  1006. columnKey: 'action',
  1007. label: '操作',
  1008. width: 110,
  1009. align: 'center',
  1010. resizable: false,
  1011. slot: 'action',
  1012. fixed: 'right'
  1013. }
  1014. ];
  1015. },
  1016. cacheKeyUrl() {
  1017. return `main-permit-add-2510181429-reportWorkType`;
  1018. },
  1019. detialsDatasource() {
  1020. if (this.formData.recordTemplateStyle == '4') {
  1021. // 根据 statisticsType 过滤
  1022. return this.formData.details.filter(
  1023. (i) => i.statisticsType == this.statisticsType
  1024. );
  1025. } else {
  1026. return this.formData.details;
  1027. }
  1028. },
  1029. // 根据typeList 计算行业类型列表
  1030. // {
  1031. // "id": "1991058936943173633",
  1032. // "createTime": "2025-11-19 16:20:17",
  1033. // "createUserId": "1881891196703911938",
  1034. // "industryType": 1,
  1035. // "industryName": "工程机械",
  1036. // "businessType": 1,
  1037. // "businessName": "生产",
  1038. // "reportWorkType": 1,
  1039. // "reportWorkName": "产前准备",
  1040. // "sceneType": 1,
  1041. // "sceneName": "清场清洁",
  1042. // "templateStyleType": 1,
  1043. // "templateStyleName": "通用模板",
  1044. // "tenantId": "1",
  1045. // "deptId": "1",
  1046. // "factoriesId": "1916747066214232065"
  1047. // }
  1048. industryTypeList() {
  1049. const seen = new Set();
  1050. const res = [];
  1051. for (const i of this.typeList || []) {
  1052. const key = String(i.industryType);
  1053. if (!seen.has(key)) {
  1054. seen.add(key);
  1055. res.push({
  1056. label: i.industryName,
  1057. value: key
  1058. });
  1059. }
  1060. }
  1061. return res;
  1062. },
  1063. // 根据typeList和formData.industryType计算业务分类列表
  1064. businessTypeList() {
  1065. const seen = new Set();
  1066. const res = [];
  1067. const list = this.typeList.filter(
  1068. (i) => i.industryType == this.formData.industryType
  1069. );
  1070. for (const i of list || []) {
  1071. const key = String(i.businessType);
  1072. if (!seen.has(key)) {
  1073. seen.add(key);
  1074. res.push({
  1075. label: i.businessName,
  1076. value: key
  1077. });
  1078. }
  1079. }
  1080. return res;
  1081. },
  1082. // 根据typeList和formData.industryType、formData.businessType计算模块划分列表
  1083. reportWorkTypeList() {
  1084. const seen = new Set();
  1085. const res = [];
  1086. const list = this.typeList.filter(
  1087. (i) =>
  1088. i.industryType == this.formData.industryType &&
  1089. i.businessType == this.formData.businessType
  1090. );
  1091. for (const i of list || []) {
  1092. const key = String(i.reportWorkType);
  1093. if (!seen.has(key)) {
  1094. seen.add(key);
  1095. res.push({
  1096. label: i.reportWorkName,
  1097. value: key
  1098. });
  1099. }
  1100. }
  1101. return res;
  1102. },
  1103. // 根据typeList和formData.industryType、formData.businessType、formData.reportWorkType计算应用场景列表
  1104. classifyList() {
  1105. const seen = new Set();
  1106. const res = [];
  1107. const list = this.typeList.filter(
  1108. (i) =>
  1109. i.industryType == this.formData.industryType &&
  1110. i.businessType == this.formData.businessType &&
  1111. i.reportWorkType == this.formData.reportWorkType
  1112. );
  1113. for (const i of list || []) {
  1114. const key = String(i.sceneType);
  1115. if (!seen.has(key)) {
  1116. seen.add(key);
  1117. res.push({
  1118. label: i.sceneName,
  1119. value: key
  1120. });
  1121. }
  1122. }
  1123. return res;
  1124. },
  1125. // 根据typeList和formData.industryType、formData.businessType、formData.reportWorkType、formData.classify计算模板样式列表
  1126. recordTemplateStyleList() {
  1127. const seen = new Set();
  1128. const res = [];
  1129. const list = this.typeList.filter(
  1130. (i) =>
  1131. i.industryType == this.formData.industryType &&
  1132. i.businessType == this.formData.businessType &&
  1133. i.reportWorkType == this.formData.reportWorkType &&
  1134. i.sceneType == this.formData.classify
  1135. );
  1136. for (const i of list || []) {
  1137. const key = String(i.templateStyleType);
  1138. if (!seen.has(key)) {
  1139. seen.add(key);
  1140. res.push({
  1141. label: i.templateStyleName,
  1142. value: key
  1143. });
  1144. }
  1145. }
  1146. return res;
  1147. }
  1148. },
  1149. data() {
  1150. const formDateBase = {
  1151. id: null,
  1152. deviceId: null,
  1153. deviceName: '',
  1154. frequencyUnit: 2,
  1155. frequencyValue: null,
  1156. name: '',
  1157. details: [],
  1158. recordRulesCycleList: [],
  1159. startDate: null,
  1160. stopDate: null,
  1161. version: 1,
  1162. code: '',
  1163. fromId: null,
  1164. // 行业类型
  1165. industryType: null,
  1166. // 业务分类
  1167. businessType: null,
  1168. // 记录规则类型|应用场景
  1169. classify: null,
  1170. // 模块分类 参考字典项:record_rules_report_work_type
  1171. reportWorkType: null,
  1172. // 模板样式
  1173. recordTemplateStyle: null,
  1174. // 执行方式
  1175. isExecuteMethod: 0,
  1176. executeMethodId: null,
  1177. executeMethodName: '',
  1178. produceTaskConfigs: [],
  1179. bigVersion: '',
  1180. versionMark: '',
  1181. smallVersion: '',
  1182. produceTaskId: '',
  1183. produceTaskName: '',
  1184. codeNumber: ''
  1185. };
  1186. return {
  1187. dialogTitle: '',
  1188. visible: false,
  1189. formDateBase,
  1190. formData: JSON.parse(JSON.stringify(formDateBase)),
  1191. formRules: {
  1192. name: [{ required: true, message: '请输入名称', trigger: 'blur' }],
  1193. frequencyValue: [
  1194. { required: true, message: '请选择周期', trigger: 'blur' },
  1195. { required: true, message: '请选择周期', trigger: 'change' }
  1196. ],
  1197. frequencyUnit: [
  1198. { required: true, message: '请选择频率单位', trigger: 'change' }
  1199. ],
  1200. classify: [
  1201. { required: true, message: '请选择规则类型', trigger: 'change' }
  1202. ],
  1203. // startDate 启用日期要大于当前时间
  1204. // stopDate 停用时间要大于当前时间并且大于启用日期
  1205. // startDate: [
  1206. // { required: true, message: '请选择启用日期', trigger: 'blur' },
  1207. // { required: true, message: '请选择启用日期', trigger: 'change' },
  1208. // { validator: this.validateStartDate, trigger: 'change' }
  1209. // ],
  1210. // stopDate: [
  1211. // { required: true, message: '请选择停用时间', trigger: 'change' },
  1212. // { validator: this.validateStopDate, trigger: 'change' }
  1213. // ],
  1214. deviceName: [
  1215. { required: true, message: '请输入选择设备', trigger: 'blur' }
  1216. ],
  1217. businessType: [
  1218. { required: true, message: '请选择业务分类', trigger: 'blur' },
  1219. { required: true, message: '请选择业务分类', trigger: 'change' }
  1220. ],
  1221. industryType: [
  1222. { required: true, message: '请选择业行业类别', trigger: 'blur' },
  1223. { required: true, message: '请选择业行业类别', trigger: 'change' }
  1224. ],
  1225. reportWorkType: [
  1226. { required: true, message: '请选择业模块划分', trigger: 'blur' },
  1227. { required: true, message: '请选择业模块划分', trigger: 'change' }
  1228. ],
  1229. classify: [
  1230. { required: true, message: '请选择应用场景', trigger: 'blur' },
  1231. { required: true, message: '请选择应用场景', trigger: 'change' }
  1232. ],
  1233. recordTemplateStyle: [
  1234. { required: true, message: '请选择模板样式', trigger: 'blur' },
  1235. { required: true, message: '请选择模板样式', trigger: 'change' }
  1236. ],
  1237. executeMethodId: [
  1238. { required: true, message: '请选择执行方式', trigger: 'change' },
  1239. { required: true, message: '请选择执行方式', trigger: 'blur' }
  1240. ]
  1241. },
  1242. recordSheet: [], // 记录表
  1243. current: {},
  1244. dataIndex: null,
  1245. showEdit: false,
  1246. btnLoading: false,
  1247. currentRow: null,
  1248. type: '',
  1249. // 产品分类
  1250. productCategory: [],
  1251. loading: false,
  1252. produceTaskCode: '',
  1253. // 执行方式列表
  1254. executeMethodList: [],
  1255. // 1-成品统计,2-物料统计,3-工序统计"
  1256. statisticsType: '1',
  1257. statisticsTypeList: [
  1258. { label: '成品统计', value: '1' },
  1259. { label: '物料统计', value: '2' },
  1260. { label: '工序统计', value: '3' }
  1261. ],
  1262. opSelectOptions: ['+', '-', '*', '/', '%', '(', ')'],
  1263. typeList: [],
  1264. currentIndex: ''
  1265. };
  1266. },
  1267. mounted() {
  1268. this.getByCodeData();
  1269. this.getProductCategory();
  1270. console.log('this.formData 2233', this.formData);
  1271. this.getTypeList();
  1272. },
  1273. methods: {
  1274. open(row, type, title) {
  1275. this.dialogTitle = title;
  1276. this.type = type;
  1277. console.log('type', type, row);
  1278. this.getTypeList();
  1279. if (
  1280. type == 'edit' ||
  1281. type == 'detail' ||
  1282. type == 'change' ||
  1283. type == 'clone'
  1284. ) {
  1285. this.getDetils(row.id);
  1286. }
  1287. // 过程控制临时修改
  1288. if (type == 'processEdit') {
  1289. this.processEditSetValue(row);
  1290. }
  1291. if (type == 'add') {
  1292. this.formData.version = 1;
  1293. // 启用日期 默认为 今天
  1294. this.formData.startDate = new Date();
  1295. // 停用日期 默认为 2099-12-31
  1296. this.formData.stopDate = new Date('2099-12-31 00:00:00');
  1297. console.log('this.typeInfo', this.typeInfo);
  1298. // 类型
  1299. if (this.typeInfo) {
  1300. const node = this.typeInfo;
  1301. const item = node.item || node;
  1302. if (this.businessType) {
  1303. this.formData.businessType = this.businessType + '';
  1304. this.formData.businessName =
  1305. this.businessType == '1' ? '生产' : '质检';
  1306. }
  1307. switch (node.type) {
  1308. case 'industry':
  1309. this.formData.industryType = item.industryType + '';
  1310. break;
  1311. case 'business':
  1312. this.formData.industryType = item.industryType + '';
  1313. this.formData.businessType = item.businessType + '';
  1314. break;
  1315. case 'reportWork':
  1316. this.formData.industryType = item.industryType + '';
  1317. this.formData.businessType = item.businessType + '';
  1318. this.formData.reportWorkType = item.reportWorkType + '';
  1319. break;
  1320. case 'scene':
  1321. this.formData.industryType = item.industryType + '';
  1322. this.formData.businessType = item.businessType + '';
  1323. this.formData.reportWorkType = item.reportWorkType + '';
  1324. this.formData.classify = item.sceneType + '';
  1325. break;
  1326. case 'templateStyle':
  1327. this.formData.industryType = item.industryType + '';
  1328. this.formData.businessType = item.businessType + '';
  1329. this.formData.reportWorkType = item.reportWorkType + '';
  1330. this.formData.classify = item.sceneType + '';
  1331. this.formData.recordTemplateStyle = item.templateStyleType + '';
  1332. break;
  1333. default:
  1334. // 直接赋值所有可用字段(兜底)
  1335. if (item.industryType != null)
  1336. this.formData.industryType = item.industryType + '';
  1337. if (item.businessType != null)
  1338. this.formData.businessType = item.businessType + '';
  1339. if (item.reportWorkType != null)
  1340. this.formData.reportWorkType = item.reportWorkType + '';
  1341. if (item.sceneType != null)
  1342. this.formData.classify = item.sceneType + '';
  1343. if (item.templateStyleType != null)
  1344. this.formData.recordTemplateStyle =
  1345. item.templateStyleType + '';
  1346. break;
  1347. }
  1348. }
  1349. }
  1350. this.visible = true;
  1351. console.log('this.formData', this.formData);
  1352. },
  1353. addSupplier(row, index) {
  1354. this.currentIndex = index;
  1355. this.$refs.supplierSelectionRef.open();
  1356. },
  1357. confirmStaffSelection1(data = []) {
  1358. this.$set(
  1359. this.formData.details[this.currentIndex],
  1360. 'supplierName',
  1361. data.map((item) => item.name).toString()
  1362. );
  1363. this.$set(
  1364. this.formData.details[this.currentIndex],
  1365. 'supplierId',
  1366. data.map((item) => item.id).toString()
  1367. );
  1368. },
  1369. // 过程控制 修改规则详情
  1370. async processEditSetValue(row) {
  1371. const data = await recordrulesGetById(row.rulesId);
  1372. const info = JSON.parse(JSON.stringify(row));
  1373. data.details = info.produceTaskConfigRuleDetails;
  1374. // 处理详情的 公式 字段
  1375. data.details.forEach((item) => {
  1376. if (item.paramType == 9 && item.formula) {
  1377. // formula格式为[A][+][b][*][C] 拆分 -> ['A','+','b','*','C']
  1378. if (item.formula) {
  1379. const matches = item.formula.match(/\[([^\]]+)\]/g);
  1380. if (matches) {
  1381. this.$set(
  1382. item,
  1383. 'formulaParts',
  1384. matches.map((m) => m.slice(1, -1)).filter(Boolean)
  1385. );
  1386. }
  1387. } else {
  1388. this.$set(item, 'formulaParts', []);
  1389. }
  1390. }
  1391. });
  1392. this.$util.assignObject(this.formData, data);
  1393. this.$nextTick(() => {
  1394. this.$refs.cycleMultipleRef?.setRecordRulesCycleList(
  1395. this.formData.recordRulesCycleList
  1396. );
  1397. });
  1398. this.formData.executeMethodId = info.recordRulesExecuteMethodId;
  1399. this.formData.executeMethodName = info.recordRulesExecuteMethodName;
  1400. this.formData.startDate = new Date(info.startDate || data.startDate);
  1401. this.formData.stopDate = new Date(info.stopDate || data.stopDate);
  1402. this.formData.classify = this.formData.classify + '';
  1403. this.formData.reportWorkType = this.formData.reportWorkType + '';
  1404. this.formData.industryType = this.formData.industryType + '';
  1405. this.formData.businessType = this.formData.businessType + '';
  1406. this.formData.reportWorkType = this.formData.reportWorkType + '';
  1407. this.formData.recordTemplateStyle =
  1408. this.formData.recordTemplateStyle + '';
  1409. console.log('this.formData~~~~', this.formData);
  1410. this.getExecuteMethodList();
  1411. this.loading = false;
  1412. },
  1413. async getDetils(id) {
  1414. this.loading = true;
  1415. try {
  1416. const data = await recordrulesGetById(id);
  1417. this.$util.assignObject(this.formData, data);
  1418. this.$nextTick(() => {
  1419. this.$refs.cycleMultipleRef?.setRecordRulesCycleList(
  1420. this.formData.recordRulesCycleList
  1421. );
  1422. if (this.businessType == 3|| this.formData.reportWorkType == 6) {
  1423. this.$refs.experimentationProcess.init(data.tempJson.tempJson);
  1424. }
  1425. });
  1426. this.formData.startDate = new Date(data.startDate);
  1427. this.formData.stopDate = new Date(data.stopDate);
  1428. this.formData.classify = this.formData.classify + '';
  1429. this.formData.industryType = this.formData.industryType + '';
  1430. this.formData.businessType = this.formData.businessType + '';
  1431. this.formData.reportWorkType = this.formData.reportWorkType + '';
  1432. this.formData.recordTemplateStyle =
  1433. this.formData.recordTemplateStyle + '';
  1434. if (this.type == 'change') {
  1435. this.formData.fromId = id;
  1436. this.formData.id = null;
  1437. }
  1438. if (this.type == 'clone') {
  1439. this.formData.fromId = null;
  1440. this.formData.id = null;
  1441. this.formData.produceTaskId = null;
  1442. this.formData.produceTaskName = null;
  1443. this.formData.executeMethodId = null;
  1444. this.formData.executeMethodName = '';
  1445. this.executeMethodList = [];
  1446. // startDate 小于当前日期则取当前日期
  1447. const now = new Date();
  1448. if (this.formData.startDate < now) {
  1449. this.formData.startDate = now;
  1450. }
  1451. } else {
  1452. this.getExecuteMethodList();
  1453. }
  1454. // 处理详情的 公式 字段
  1455. this.formData.details.forEach((item) => {
  1456. if (item.paramType == 9 && item.formula) {
  1457. // formula格式为[A][+][b][*][C] 拆分 -> ['A','+','b','*','C']
  1458. if (item.formula) {
  1459. const matches = item.formula.match(/\[([^\]]+)\]/g);
  1460. if (matches) {
  1461. this.$set(
  1462. item,
  1463. 'formulaParts',
  1464. matches.map((m) => m.slice(1, -1)).filter(Boolean)
  1465. );
  1466. }
  1467. } else {
  1468. this.$set(item, 'formulaParts', []);
  1469. }
  1470. this.$set(item, '_paramSelect', null);
  1471. this.$set(item, '_opSelect', null);
  1472. this.$set(item, '_replaceOrAppend', '');
  1473. }
  1474. });
  1475. this.loading = false;
  1476. } catch (error) {
  1477. console.log(error, 'error');
  1478. this.loading = false;
  1479. }
  1480. },
  1481. async getByCodeData() {
  1482. let res = await getByCode('record_sheet');
  1483. let list = res.data.map((item) => {
  1484. let values = Object.keys(item);
  1485. return {
  1486. value: values[0],
  1487. label: item[values[0]]
  1488. };
  1489. });
  1490. this.recordSheet = list;
  1491. console.log('this.recordSheet', this.recordSheet);
  1492. },
  1493. itemDel(index) {
  1494. this.formData.details.splice(index, 1);
  1495. },
  1496. /* 打开操作手册编辑款 */
  1497. openOperationGuideDialogDialog(row, index) {
  1498. this.$refs.operationGuideDialog.open(row, index);
  1499. },
  1500. handleClose() {
  1501. // 清空表单数据
  1502. this.formData = JSON.parse(JSON.stringify(this.formDateBase));
  1503. this.executeMethodList = [];
  1504. this.$refs['formRef'].resetFields();
  1505. this.visible = false;
  1506. },
  1507. // 保存
  1508. confirm() {
  1509. console.log('this.formData', this.formData);
  1510. // 验证表单规则
  1511. this.$refs.formRef.validate(async (valid) => {
  1512. if (!valid) {
  1513. return false;
  1514. }
  1515. if (
  1516. this.formData.details.length == 0 &&
  1517. this.businessType != 3 &&
  1518. this.formData.reportWorkType != 6
  1519. ) {
  1520. return this.$message.warning('至少选择一条规则项');
  1521. }
  1522. try {
  1523. const valid = this.validateFormula();
  1524. if (!valid) {
  1525. return;
  1526. }
  1527. this.btnLoading = true;
  1528. const body = this.formatBody();
  1529. if (this.type == 'add' || this.type == 'clone') {
  1530. await recordrulesSave(body);
  1531. } else if (this.type == 'change') {
  1532. await recordrulesUpdateVersion(body);
  1533. } else {
  1534. // 编辑
  1535. body.fromId = null;
  1536. await recordrulesUpdate(body);
  1537. }
  1538. this.btnLoading = false;
  1539. this.$message.success('操作成功');
  1540. this.handleClose();
  1541. this.$emit('reload');
  1542. this.$emit('reloadTypeList');
  1543. } catch (error) {
  1544. console.log(error, 'dasda');
  1545. this.btnLoading = false;
  1546. }
  1547. });
  1548. },
  1549. // 保存并发布
  1550. saveAndPublish() {
  1551. // 验证表单规则
  1552. this.$refs.formRef.validate(async (valid) => {
  1553. if (!valid) {
  1554. return false;
  1555. }
  1556. if (this.businessType != 3 && this.formData.reportWorkType != 6) {
  1557. if (this.formData.details.length == 0) {
  1558. return this.$message.warning('至少选择一条规则项');
  1559. }
  1560. if (this.formData.reportWorkType == 4) {
  1561. // 生产统计过滤掉非成品统计的明细
  1562. this.formData.details = this.formData.details.filter(
  1563. (i) => i.statisticsType
  1564. );
  1565. }
  1566. // 判断参数类型是否选择
  1567. for (const detail of this.formData.details) {
  1568. if (!detail.paramType) {
  1569. console.log('detail', detail);
  1570. return this.$message.warning('请选择规则明细中的参数类型!');
  1571. }
  1572. }
  1573. }
  1574. try {
  1575. this.btnLoading = true;
  1576. const body = this.formatBody();
  1577. if (this.type != 'saveAndPublish') {
  1578. await recordrulesSaveAndPublish(body);
  1579. } else {
  1580. this.$emit('processSave', body);
  1581. }
  1582. this.btnLoading = false;
  1583. this.$message.success('操作成功');
  1584. this.handleClose();
  1585. this.$emit('reload');
  1586. } catch (error) {
  1587. console.log(error, 'error');
  1588. this.btnLoading = false;
  1589. }
  1590. });
  1591. },
  1592. // 保存或发布时验证公式是否正确
  1593. validateFormula() {
  1594. let invalid = false;
  1595. this.formData.details.forEach((detail) => {
  1596. if (invalid) return; // 已发现无效,后续直接跳过避免重复提示
  1597. if (detail.paramType == 9) {
  1598. const formula = detail.formula;
  1599. if (!formula || !formula.trim()) {
  1600. console.log('formula', formula);
  1601. this.$message.warning('规则明细中计算类型的公式不能为空!');
  1602. invalid = true;
  1603. }
  1604. // 解析公式为 token 列表
  1605. const rawTokens = (formula.match(/\[([^\]]+)\]/g) || [])
  1606. .map((m) => m.slice(1, -1))
  1607. .filter(Boolean);
  1608. if (!rawTokens.length) {
  1609. console.log('rawTokens', rawTokens, formula);
  1610. this.$message.warning('规则明细中计算类型的公式不能为空!');
  1611. invalid = true;
  1612. return;
  1613. }
  1614. const operators = new Set(this.opSelectOptions);
  1615. const availableParams = this.formData.details
  1616. .filter((d) => d !== detail && d.paramType != 9 && d.paramValue)
  1617. .map((d) => d.paramValue);
  1618. const varsSet = new Set();
  1619. let parenBalance = 0;
  1620. let lastWasOperator = true; // 开头不能是普通数字/变量
  1621. let expression = '';
  1622. for (let i = 0; i < rawTokens.length; i++) {
  1623. const t = rawTokens[i];
  1624. if (invalid) break;
  1625. if (operators.has(t)) {
  1626. // 括号
  1627. if (t === '(') {
  1628. parenBalance++;
  1629. lastWasOperator = true;
  1630. } else if (t === ')') {
  1631. parenBalance--;
  1632. if (parenBalance < 0) {
  1633. this.$message.warning('公式括号不匹配');
  1634. invalid = true;
  1635. break;
  1636. }
  1637. lastWasOperator = false;
  1638. } else {
  1639. // 普通运算符不能连续出现
  1640. if (lastWasOperator) {
  1641. this.$message.warning('公式存在连续运算符或位置不合法');
  1642. invalid = true;
  1643. break;
  1644. }
  1645. lastWasOperator = true;
  1646. }
  1647. expression += t;
  1648. } else {
  1649. // 变量
  1650. if (!t.trim()) {
  1651. this.$message.warning('公式中存在空变量');
  1652. invalid = true;
  1653. break;
  1654. }
  1655. // 变量前必须是运算符或者开头或左括号
  1656. if (!lastWasOperator) {
  1657. this.$message.warning('公式中变量之间缺少运算符');
  1658. invalid = true;
  1659. break;
  1660. }
  1661. varsSet.add(t);
  1662. // 校验变量是否存在于其他明细 排除要求生产数量
  1663. if (!availableParams.includes(t) && t != '要求生产数量') {
  1664. this.$message.warning(
  1665. `公式中引用的参数 "${t}" 未在非计算类型的明细中定义`
  1666. );
  1667. invalid = true;
  1668. break;
  1669. }
  1670. // 用顺序数字替换变量
  1671. expression += varsSet.size; // 1,2,3...
  1672. lastWasOperator = false;
  1673. }
  1674. }
  1675. if (invalid) return;
  1676. if (parenBalance !== 0) {
  1677. this.$message.warning('公式括号不匹配');
  1678. invalid = true;
  1679. return;
  1680. }
  1681. if (lastWasOperator) {
  1682. this.$message.warning('公式不能以运算符结尾');
  1683. invalid = true;
  1684. return;
  1685. }
  1686. // 最终表达式字符合法性校验
  1687. if (!/^[0-9+\-*/%() ]+$/.test(expression)) {
  1688. this.$message.warning('公式包含非法字符');
  1689. invalid = true;
  1690. return;
  1691. }
  1692. // 计算测试
  1693. try {
  1694. const result = Function(`"use strict";return (${expression})`)();
  1695. if (Number.isNaN(result) || !isFinite(result)) {
  1696. this.$message.warning('公式计算结果非法');
  1697. invalid = true;
  1698. return;
  1699. }
  1700. } catch (e) {
  1701. this.$message.warning('公式计算失败,请检查语法');
  1702. invalid = true;
  1703. return;
  1704. }
  1705. // 回填拆分后的 parts
  1706. detail.formulaParts = rawTokens;
  1707. }
  1708. });
  1709. if (invalid) {
  1710. return false;
  1711. }
  1712. return true;
  1713. },
  1714. // 数据格式化
  1715. formatBody() {
  1716. this.formData.recordRulesCycleList =
  1717. this.$refs.cycleMultipleRef &&
  1718. this.$refs.cycleMultipleRef.recordRulesCycleList
  1719. .map((i) => {
  1720. // 根据月日时分排序计算权重排序
  1721. let sortNum = 0;
  1722. if (i.month) {
  1723. sortNum += i.month * 60 * 24 * 30;
  1724. }
  1725. if (i.day) {
  1726. sortNum += i.day * 60 * 24;
  1727. }
  1728. if (i.hour) {
  1729. sortNum += i.hour * 60;
  1730. }
  1731. if (i.minute) {
  1732. sortNum += i.minute * 1;
  1733. }
  1734. return { ...i, sortNum };
  1735. })
  1736. .sort((a, b) => a.sortNum - b.sortNum)
  1737. .map((i, index) => {
  1738. return { ...i, sortNum: index + 1 };
  1739. });
  1740. const body = JSON.parse(JSON.stringify(this.formData));
  1741. body.startDate = this.$util.toDateString(
  1742. body.startDate,
  1743. 'yyyy-MM-dd HH:mm:ss'
  1744. );
  1745. body.stopDate = this.$util.toDateString(
  1746. body.stopDate,
  1747. 'yyyy-MM-dd HH:mm:ss'
  1748. );
  1749. if (this.businessType == 3 || this.formData.reportWorkType == 6) {
  1750. let tempJson = this.$refs.experimentationProcess.getValue();
  1751. if (tempJson) {
  1752. body.tempJson = {
  1753. tempJson: JSON.stringify(tempJson)
  1754. };
  1755. }
  1756. }
  1757. // details 根据下标添加 sortNum
  1758. body.details = body.details.map((item, index) => {
  1759. return { ...item };
  1760. });
  1761. return body;
  1762. },
  1763. // startDate 启用日期要大于当前时间
  1764. validateStartDate(rule, value, callback) {
  1765. const startDate = this.formData.startDate;
  1766. if (!startDate) {
  1767. return callback(new Error('启用日期不能为空'));
  1768. }
  1769. // 启用日期大于等于今天
  1770. // const today = new Date();
  1771. // today.setHours(0, 0, 0, 0); // 设置为当天的开始时间
  1772. // if (new Date(startDate) < today) {
  1773. // return callback(new Error('启用日期必须大于等于当前日期'));
  1774. // }
  1775. callback();
  1776. },
  1777. // stopDate 停用时间要大于当前时间并且大于启用日期
  1778. validateStopDate(rule, value, callback) {
  1779. const startDate = this.formData.startDate;
  1780. const stopDate = this.formData.stopDate;
  1781. if (
  1782. stopDate &&
  1783. startDate &&
  1784. new Date(stopDate) <= new Date(startDate)
  1785. ) {
  1786. return callback(new Error('停用时间必须大于启用日期'));
  1787. }
  1788. callback();
  1789. },
  1790. // 去选择设备
  1791. selectDeviceId() {
  1792. this.currentIndex = 9999;
  1793. this.$refs.deviceSelectDialog.open([]);
  1794. },
  1795. // 选择设备回调
  1796. chooseEquipment(data, index, categoryId) {
  1797. if (this.currentIndex != 9999) {
  1798. substanceKey.forEach((key) => {
  1799. if (key != 'paramValue') {
  1800. this.$set(this.formData.details[this.currentIndex], key, '');
  1801. }
  1802. });
  1803. this.$set(
  1804. this.formData.details[this.currentIndex],
  1805. 'substanceId',
  1806. data.id
  1807. );
  1808. this.$set(
  1809. this.formData.details[this.currentIndex],
  1810. 'substanceName',
  1811. data.name
  1812. );
  1813. this.$set(
  1814. this.formData.details[this.currentIndex],
  1815. 'substanceCode',
  1816. data.code
  1817. );
  1818. return;
  1819. }
  1820. this.formData.deviceId = data?.id || null;
  1821. this.formData.deviceName = data?.name || '';
  1822. this.formData.codeNumber = data?.codeNumber || '';
  1823. if (this.formData.reportWorkType == 5) {
  1824. this.formData.details = this.formData.details.filter(
  1825. (item) => !item.paramCode
  1826. );
  1827. }
  1828. },
  1829. // 添加
  1830. addRow() {
  1831. // 最大sortNum 值 +1
  1832. let sortNum = 1;
  1833. if (this.formData.details.length > 0) {
  1834. const maxSortNum = Math.max(
  1835. ...this.formData.details.map((item) => item.sortNum || 0)
  1836. );
  1837. sortNum = maxSortNum + 1;
  1838. }
  1839. this.formData.details.push({
  1840. id: new Date().getTime(),
  1841. defaultValue: '',
  1842. maxValue: null,
  1843. minValue: null,
  1844. paramType: null,
  1845. paramValue: null,
  1846. remark: '',
  1847. symbol: null,
  1848. tools: [],
  1849. unitName: null,
  1850. productName: '',
  1851. productCode: '',
  1852. paramCode: '',
  1853. substanceId: '',
  1854. substanceCode: '',
  1855. substanceName: '',
  1856. // 1-成品统计,2-物料统计,3-工序统计"
  1857. statisticsType:
  1858. this.formData.recordTemplateStyle == '4'
  1859. ? this.statisticsType
  1860. : null,
  1861. // 公式
  1862. formula: '',
  1863. _paramSelect: null,
  1864. _opSelect: null,
  1865. _replaceOrAppend: '',
  1866. formulaParts: [],
  1867. sortNum
  1868. });
  1869. console.log('this.formData.details', this.formData.details);
  1870. },
  1871. deleteRow(row) {
  1872. const index = this.formData.details.indexOf(row);
  1873. if (index !== -1) {
  1874. this.formData.details.splice(index, 1);
  1875. }
  1876. },
  1877. handleAdd(row, index, type) {
  1878. this.currentRow = row;
  1879. this.currentIndex = index;
  1880. if (type == 'iotPointName') {
  1881. if (!this.formData.deviceId) {
  1882. this.$message.error('请选择主设备!');
  1883. return;
  1884. }
  1885. this.$refs.bindSubstanceRef.open(
  1886. this.formData.deviceId,
  1887. this.formData.deviceName,
  1888. this.formData.deviceCode
  1889. );
  1890. } else if (type == 'substanceName') {
  1891. this.$refs.deviceSelectDialog.open([]);
  1892. } else {
  1893. this.$refs.toolModalRef.open(row.toolCodes);
  1894. }
  1895. },
  1896. bindSubstanceListOpen() {
  1897. this.currentIndex = 9999;
  1898. this.$refs.bindSubstanceRef.open(
  1899. this.formData.deviceId,
  1900. this.formData.deviceName,
  1901. this.formData.deviceCode
  1902. );
  1903. },
  1904. bindSubstanceSuccess(list) {
  1905. console.log(list, 'list');
  1906. const currentIndex = this.currentIndex;
  1907. list.forEach((item, index) => {
  1908. if (!index && currentIndex != 9999) {
  1909. substanceKey.forEach((key) => {
  1910. this.$set(this.formData.details[currentIndex], key, item[key]);
  1911. });
  1912. this.$set(this.formData.details[currentIndex], 'paramType', 7);
  1913. } else {
  1914. this.formData.details.push({
  1915. id: new Date().getTime(),
  1916. defaultValue: '',
  1917. maxValue: item.maxValue,
  1918. minValue: item.minValue,
  1919. paramType: 7,
  1920. paramValue: item.paramValue,
  1921. remark: '',
  1922. symbol: null,
  1923. tools: [],
  1924. unitName: item.unitName,
  1925. productName: '',
  1926. productCode: '',
  1927. paramCode: item.paramCode,
  1928. iotPointName: item.paramValue,
  1929. iotId: item.iotId,
  1930. substanceId: item.substanceId,
  1931. substanceCode: item.substanceCode,
  1932. substanceName: item.substanceName,
  1933. // 1-成品统计,2-物料统计,3-工序统计"
  1934. statisticsType:
  1935. this.formData.recordTemplateStyle == '4'
  1936. ? this.statisticsType
  1937. : null,
  1938. // 公式
  1939. formula: '',
  1940. _paramSelect: null,
  1941. _opSelect: null,
  1942. _replaceOrAppend: '',
  1943. formulaParts: [],
  1944. sortNum:
  1945. Math.max(
  1946. ...this.formData.details.map((item) => item.sortNum || 0)
  1947. ) + 1
  1948. });
  1949. }
  1950. });
  1951. },
  1952. chooseModal(data) {
  1953. console.log('data', data);
  1954. this.currentRow.tools = data.map((i) => {
  1955. return {
  1956. toolCode: i.code,
  1957. toolName: i.name
  1958. };
  1959. });
  1960. },
  1961. // 规则明细表
  1962. async recordrulesDetailPage(row) {
  1963. const { list } = await recordrulesDetailPage({
  1964. // deptId: row.deptId,
  1965. pageNum: 1,
  1966. rulesId: row.id,
  1967. size: 9999
  1968. });
  1969. console.log('list 数据', list);
  1970. this.formData.details = list;
  1971. },
  1972. // 清空工具
  1973. clearTool(row, index) {
  1974. if (type == 'substanceName') {
  1975. substanceKey.forEach((key) => {
  1976. this.$set(this.formData.details[index], key, '');
  1977. });
  1978. } else {
  1979. row.tools = [];
  1980. }
  1981. },
  1982. // 查询 recordrulesCyclePage
  1983. async recordrulesCyclePage(row) {
  1984. const { list } = await recordrulesCyclePage({
  1985. pageNum: 1,
  1986. size: 9999,
  1987. recordRulesId: row.id,
  1988. orderBy: 'descending'
  1989. });
  1990. console.log('list 周期数据', list);
  1991. this.formData.recordRulesCycleList = list;
  1992. this.$nextTick(() => {
  1993. this.$refs.cycleMultipleRef.setRecordRulesCycleList(list);
  1994. });
  1995. },
  1996. // 去选择产品
  1997. selectProduct(row) {
  1998. this.currentRow = row;
  1999. this.$refs.ProductModalRef.open();
  2000. },
  2001. // 选择产品
  2002. changeProduct(current) {
  2003. console.log('current', current);
  2004. this.currentRow.productName = current.name;
  2005. this.currentRow.productCode = current.code;
  2006. },
  2007. // 选择物品 产品、物料等
  2008. selectChooseModalProduct(row) {
  2009. this.currentRow = row;
  2010. this.$refs.toolModalTowRef.open([], '选择物品');
  2011. },
  2012. chooseModalProduct(current) {
  2013. console.log('current', current);
  2014. this.currentRow.productName = current.name;
  2015. this.currentRow.productCode = current.code;
  2016. this.currentRow.unitName = current.weightUnit;
  2017. console.log('this.currentRow', this.currentRow);
  2018. },
  2019. // 清空产品
  2020. clearProduct(row) {
  2021. row.productName = '';
  2022. row.productCode = '';
  2023. },
  2024. // 获取产品分类
  2025. async getProductCategory() {
  2026. let { data } = await getTreeByPid(9);
  2027. console.log('产品分类', data);
  2028. this.productCategory = data;
  2029. },
  2030. // 选择工序
  2031. openProduceTaskDialog() {
  2032. this.$refs.processModalRef.open();
  2033. },
  2034. // 工序
  2035. processChooseProcess(process) {
  2036. console.log('选择的工序', process);
  2037. this.formData.produceTaskId = process.id;
  2038. this.formData.produceTaskName = process.name;
  2039. this.formData.executeMethodId = null;
  2040. this.formData.executeMethodName = '';
  2041. // 查询工序下的执行方式
  2042. this.getExecuteMethodList();
  2043. },
  2044. clearProductTask() {
  2045. this.formData.produceTaskId = '';
  2046. this.formData.produceTaskName = '';
  2047. this.formData.executeMethodId = null;
  2048. this.formData.executeMethodName = '';
  2049. this.executeMethodList = [];
  2050. },
  2051. // 查询执行方式
  2052. async getExecuteMethodList() {
  2053. if (
  2054. this.formData.produceTaskId == '' &&
  2055. this.formData.reportWorkType == 2
  2056. ) {
  2057. this.executeMethodList = [];
  2058. return;
  2059. }
  2060. const data = await recordrulesexecutemethodPage({
  2061. pageNum: 1,
  2062. size: 9999,
  2063. enable: 1,
  2064. produceTaskId: this.formData.produceTaskId
  2065. });
  2066. this.executeMethodList = data.list;
  2067. // 有执行方式
  2068. if (
  2069. this.executeMethodList.length &&
  2070. this.formData.reportWorkType == 2
  2071. ) {
  2072. this.formData.isExecuteMethod = 1;
  2073. }
  2074. },
  2075. // 过程控制修改 保存
  2076. processEditSave() {
  2077. // 只验证详情内容
  2078. if (this.businessType != 3) {
  2079. if (this.formData.details.length == 0) {
  2080. return this.$message.warning('至少选择一条规则项');
  2081. }
  2082. // 判断参数类型是否选择
  2083. for (const detail of this.formData.details) {
  2084. if (!detail.paramType) {
  2085. return this.$message.warning('请选择规则明细中的参数类型!');
  2086. }
  2087. }
  2088. }
  2089. this.$emit('processSave', this.formatBody());
  2090. this.handleClose();
  2091. },
  2092. // 执行方式改变 同步执行方式名称
  2093. executeMethodIdChange() {
  2094. const selected = this.executeMethodList.find(
  2095. (item) => item.id === this.formData.executeMethodId
  2096. );
  2097. if (selected) {
  2098. this.formData.executeMethodName = selected.name;
  2099. } else {
  2100. this.formData.executeMethodName = '';
  2101. }
  2102. },
  2103. isExecuteMethodChange() {
  2104. if (this.formData.isExecuteMethod == 0) {
  2105. this.formData.executeMethodId = null;
  2106. this.formData.executeMethodName = '';
  2107. }
  2108. },
  2109. classifyChagne() {
  2110. // 生产统计
  2111. if (this.formData.recordTemplateStyle == '4') {
  2112. // 模块分类- 生产统计
  2113. this.formData.reportWorkType = '4';
  2114. // 清空规则明细
  2115. this.formData.details = [];
  2116. // 重置统计类型
  2117. this.statisticsType = '1';
  2118. } else {
  2119. if (this.formData.reportWorkType == '4') {
  2120. this.formData.reportWorkType = '1';
  2121. }
  2122. }
  2123. },
  2124. // 基于详情返回selectOptions
  2125. getSelectOptionsByDetails(statisticsType) {
  2126. let paramTypeOptions = [];
  2127. for (const detail of this.formData.details.filter(
  2128. (i) => i.statisticsType == statisticsType
  2129. )) {
  2130. if (detail.paramType != 9 || !detail.paramType) {
  2131. paramTypeOptions.push({
  2132. value: detail.paramValue,
  2133. label: detail.paramValue
  2134. });
  2135. }
  2136. }
  2137. // 过滤空值
  2138. paramTypeOptions = paramTypeOptions.filter((i) => i.value);
  2139. // 追加一个 (要求生产数量)
  2140. paramTypeOptions.push({
  2141. value: '要求生产数量',
  2142. label: '要求生产数量'
  2143. });
  2144. return paramTypeOptions;
  2145. },
  2146. paramSelectChange(val, row) {
  2147. if (!val) return;
  2148. row.formulaParts = row.formulaParts || [];
  2149. if (row.activeIndex != undefined) {
  2150. if (!row._replaceOrAppend || row._replaceOrAppend === 'replace') {
  2151. row.formulaParts.splice(row.activeIndex, 1, val);
  2152. } else if (row._replaceOrAppend === 'append') {
  2153. row.formulaParts.splice(row.activeIndex + 1, 0, val);
  2154. // 追加后activeIndex后移一位
  2155. this.$set(row, 'activeIndex', row.activeIndex + 1);
  2156. }
  2157. // row.activeIndex = undefined;
  2158. } else {
  2159. row.formulaParts.push(val);
  2160. }
  2161. row.formula = row.formulaParts.map((p) => `[${p}]`).join('');
  2162. row._paramSelect = null;
  2163. },
  2164. opSelectChange(val, row) {
  2165. if (!val) return;
  2166. row.formulaParts = row.formulaParts || [];
  2167. if (row.activeIndex != undefined) {
  2168. if (!row._replaceOrAppend || row._replaceOrAppend === 'replace') {
  2169. row.formulaParts.splice(row.activeIndex, 1, val);
  2170. } else if (row._replaceOrAppend === 'append') {
  2171. row.formulaParts.splice(row.activeIndex + 1, 0, val);
  2172. // 追加后activeIndex后移一位
  2173. this.$set(row, 'activeIndex', row.activeIndex + 1);
  2174. }
  2175. // row.activeIndex = undefined;
  2176. } else {
  2177. row.formulaParts.push(val);
  2178. }
  2179. row.formula = row.formulaParts.map((p) => `[${p}]`).join('');
  2180. row._opSelect = null;
  2181. },
  2182. tagItemDelete(index, row) {
  2183. if (this.type == 'detail') return;
  2184. row.formulaParts.splice(index, 1);
  2185. row.formula = row.formulaParts.map((p) => `[${p}]`).join('');
  2186. },
  2187. formulaPartsTagClick(index, row) {
  2188. if (this.type == 'detail') return;
  2189. if (!row._replaceOrAppend) {
  2190. // 默认追加
  2191. row._replaceOrAppend = 'append';
  2192. }
  2193. if (row.activeIndex && row.activeIndex === index) {
  2194. this.$set(row, 'activeIndex', undefined);
  2195. } else {
  2196. this.$set(row, 'activeIndex', index);
  2197. }
  2198. },
  2199. // 类型变化
  2200. paramTypeChange(row) {
  2201. if (row.pageType != 9) {
  2202. // 清空
  2203. row.formulaParts = [];
  2204. row.formula = '';
  2205. }
  2206. },
  2207. // 类型列表
  2208. async getTypeList() {
  2209. const { list = [] } = await recordrulesTypePage({
  2210. pageNum: 1,
  2211. size: 99999
  2212. });
  2213. this.typeList = list;
  2214. console.log('this.typeList', this.typeList);
  2215. },
  2216. industryTypeChange() {
  2217. this.formData.businessType = '';
  2218. this.formData.reportWorkType = '';
  2219. this.formData.classify = '';
  2220. this.formData.recordTemplateStyle = '';
  2221. },
  2222. businessTypeChange() {
  2223. this.formData.reportWorkType = '';
  2224. this.formData.classify = '';
  2225. this.formData.recordTemplateStyle = '';
  2226. },
  2227. reportWorkTypeChange() {
  2228. this.formData.classify = '';
  2229. this.formData.recordTemplateStyle = '';
  2230. },
  2231. classifyChange() {
  2232. this.formData.recordTemplateStyle = '';
  2233. }
  2234. }
  2235. };
  2236. </script>
  2237. <style scoped lang="scss">
  2238. .operationGuide_box {
  2239. width: 100%;
  2240. height: 48px;
  2241. display: flex;
  2242. overflow: hidden;
  2243. cursor: pointer;
  2244. box-sizing: border-box;
  2245. padding: 5px 10px;
  2246. .left_content {
  2247. width: 50%;
  2248. padding: 10px;
  2249. box-sizing: border-box;
  2250. border: 1px solid #c0c4cc;
  2251. border-radius: 10px;
  2252. margin-right: 10px;
  2253. overflow-y: auto;
  2254. }
  2255. .right_content {
  2256. flex: 1;
  2257. padding: 10px;
  2258. box-sizing: border-box;
  2259. border: 1px solid #c0c4cc;
  2260. border-radius: 10px;
  2261. overflow-y: auto;
  2262. }
  2263. }
  2264. ::v--deep .table_list {
  2265. .el-form-item {
  2266. .el-form-item__content {
  2267. margin-left: 0;
  2268. }
  2269. }
  2270. }
  2271. .formula-builder {
  2272. .formula-builder__selects {
  2273. margin-bottom: 6px;
  2274. display: flex;
  2275. flex-shrink: 0;
  2276. }
  2277. }
  2278. :deep(.el-dialog:not(.ele-dialog-form) .el-dialog__body .el-form) {
  2279. .el-form-item:last-child {
  2280. margin-bottom: 22px;
  2281. }
  2282. }
  2283. </style>