permitAdd.vue 69 KB

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