permitAdd.vue 71 KB

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