permitAdd.vue 74 KB

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