permitAdd.vue 49 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594
  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 style="margin-bottom: 10px">
  22. <el-col :span="8">
  23. <el-form-item label="记录规则类型" prop="classify" required>
  24. <el-select
  25. style="width: 100%"
  26. v-model="formData.classify"
  27. placeholder="请选择"
  28. >
  29. <el-option
  30. v-for="item in recordSheet"
  31. :key="item.value"
  32. :label="item.label"
  33. :value="item.value"
  34. >
  35. </el-option>
  36. </el-select>
  37. </el-form-item>
  38. </el-col>
  39. <el-col :span="8">
  40. <el-form-item label="记录规则编码" prop="code">
  41. <el-input
  42. v-model="formData.code"
  43. :disabled="true"
  44. placeholder="系统自动生成"
  45. ></el-input>
  46. </el-form-item>
  47. </el-col>
  48. <el-col :span="8">
  49. <el-form-item label="记录规则版本">
  50. <el-input
  51. :value="versionText"
  52. disabled
  53. placeholder="系统自动生成"
  54. ></el-input>
  55. </el-form-item>
  56. </el-col>
  57. </el-row>
  58. <el-row style="margin-bottom: 10px">
  59. <el-col :span="8">
  60. <el-form-item label="记录规则名称" prop="name">
  61. <el-input v-model="formData.name" placeholder="请输入"></el-input>
  62. </el-form-item>
  63. </el-col>
  64. <el-col :span="8">
  65. <el-form-item label="启用日期" required prop="startDate">
  66. <el-date-picker
  67. v-model="formData.startDate"
  68. type="date"
  69. placeholder="请选择启用日期"
  70. style="width: 100%"
  71. ></el-date-picker>
  72. </el-form-item>
  73. </el-col>
  74. <el-col :span="8">
  75. <el-form-item label="停用日期" required prop="stopDate">
  76. <el-date-picker
  77. v-model="formData.stopDate"
  78. type="date"
  79. placeholder="请选择停用日期"
  80. style="width: 100%"
  81. />
  82. </el-form-item>
  83. </el-col>
  84. <el-col v-if="formData.classify == 3" :span="8">
  85. <el-form-item label="关联设备" prop="deviceName" required>
  86. <el-input
  87. v-model="formData.deviceName"
  88. placeholder="请选择设备"
  89. :readonly="true"
  90. >
  91. <template #append>
  92. <el-button @click="selectDeviceId">选择设备</el-button>
  93. </template>
  94. </el-input>
  95. </el-form-item>
  96. </el-col>
  97. </el-row>
  98. <el-row style="margin-bottom: 10px">
  99. <el-col :span="8">
  100. <el-form-item label="模块分类" required prop="reportWorkType">
  101. <dict-selection
  102. v-model="formData.reportWorkType"
  103. dictName="记录规则报工类型"
  104. placeholder="请选择模块"
  105. :clearable="false"
  106. ></dict-selection>
  107. </el-form-item>
  108. </el-col>
  109. <el-col v-if="formData.reportWorkType == 2" :span="8">
  110. <el-form-item label="关联工序">
  111. <el-input
  112. v-model="formData.produceTaskConfigBatchSavePo.produceTaskName"
  113. @click.native="openProduceTaskDialog"
  114. readonly
  115. placeholder="关联工序"
  116. clearable
  117. >
  118. <i
  119. v-if="formData.produceTaskConfigBatchSavePo.produceTaskName"
  120. slot="suffix"
  121. class="el-input__icon el-icon-close"
  122. size="24"
  123. @click.stop="clearProductTask"
  124. ></i>
  125. </el-input>
  126. </el-form-item>
  127. </el-col>
  128. <el-col v-if="formData.reportWorkType == 2" :span="8">
  129. <el-form-item label="是否有执行方式" label-width="130px">
  130. <el-radio-group
  131. v-model="formData.isExecuteMethod"
  132. @change="executeMethodChange"
  133. >
  134. <el-radio :label="1">是</el-radio>
  135. <el-radio :label="0">否</el-radio>
  136. </el-radio-group>
  137. </el-form-item>
  138. </el-col>
  139. </el-row>
  140. <el-row
  141. v-if="
  142. formData.reportWorkType != 0 &&
  143. formData.produceTaskConfigBatchSavePo.produceTaskId
  144. "
  145. style="margin-bottom: 10px"
  146. >
  147. <el-col
  148. v-if="
  149. formData.reportWorkType == 2 &&
  150. formData.produceTaskConfigBatchSavePo.produceTaskId
  151. "
  152. :span="8"
  153. >
  154. <el-form-item
  155. label="关联产品方式"
  156. required
  157. prop="relateProductMethod"
  158. >
  159. <el-select
  160. v-model="formData.relateProductMethod"
  161. placeholder="请选择关联产品方式"
  162. style="width: 100%"
  163. >
  164. <el-option
  165. v-for="item in relateProductMethodOpeions"
  166. :key="item.value"
  167. :label="item.label"
  168. :value="item.value"
  169. >
  170. </el-option>
  171. </el-select>
  172. </el-form-item>
  173. </el-col>
  174. <el-col v-if="formData.relateProductMethod == 1" :span="8">
  175. <el-form-item label="关联产品分类" required prop="categoryLevels">
  176. <ele-tree-select
  177. multiple
  178. clearable
  179. :data="productCategory"
  180. v-model="formData.categoryLevels"
  181. placeholder="请选择关联产品分类"
  182. default-expand-all
  183. labelKey="name"
  184. valueKey="id"
  185. />
  186. </el-form-item>
  187. </el-col>
  188. </el-row>
  189. <el-row style="margin-bottom: 10px">
  190. <el-col :span="24">
  191. <el-form-item label="周期" prop="frequencyValue" required>
  192. <rule-cycle
  193. ref="cycleMultipleRef"
  194. :formData="formData"
  195. :pageType="type"
  196. />
  197. </el-form-item>
  198. </el-col>
  199. </el-row>
  200. <template v-if="formData.relateProductMethod == 2">
  201. <div style="margin-bottom: 20px">
  202. <header-title title="关联产品">
  203. <el-button
  204. size="mini"
  205. type="primary"
  206. icon="el-icon-plus"
  207. class="ele-btn-icon"
  208. @click="relateProductSelect"
  209. >
  210. 添加产品
  211. </el-button>
  212. </header-title>
  213. <ele-pro-table
  214. ref="productTableRef"
  215. :columns="productColumns"
  216. :datasource="formData.categories"
  217. :needPage="false"
  218. row-key="id"
  219. >
  220. <template v-slot:action="{ row }">
  221. <el-link
  222. type="danger"
  223. :underline="false"
  224. icon="el-icon-delete"
  225. @click="productColumnsDeleteRow(row)"
  226. >
  227. 删除
  228. </el-link>
  229. </template>
  230. </ele-pro-table>
  231. </div>
  232. </template>
  233. <header-title title="规则明细">
  234. <el-button
  235. v-if="formData.isExecuteMethod"
  236. type="primary"
  237. @click="addExecuteMethod"
  238. >添加执行方式</el-button
  239. >
  240. </header-title>
  241. <el-tabs
  242. v-if="formData.isExecuteMethod"
  243. v-model="formData.executeMethodTitle"
  244. type="card"
  245. closable
  246. @tab-remove="deleteExecuteMethod"
  247. >
  248. <el-tab-pane
  249. :key="item"
  250. v-for="item in formData.executeMethodList"
  251. :label="item"
  252. :name="item"
  253. >
  254. {{ item.content }}
  255. </el-tab-pane>
  256. </el-tabs>
  257. <ele-pro-table
  258. ref="table"
  259. :columns="bankColumns"
  260. :datasource="detailsList"
  261. :need-page="false"
  262. row-key="id"
  263. class="table_list"
  264. :cache-key="cacheKeyUrl"
  265. >
  266. <template v-slot:toolbar>
  267. <el-button
  268. type="primary"
  269. icon="el-icon-plus"
  270. class="ele-btn-icon"
  271. @click="addRow"
  272. >
  273. 新建
  274. </el-button>
  275. </template>
  276. <template v-slot:paramType="{ row }">
  277. <el-select
  278. v-model="row.paramType"
  279. placeholder="请选择参数类型"
  280. size="mini"
  281. required
  282. >
  283. <el-option label="数值" :value="1" />
  284. <el-option label="选择" :value="2" />
  285. <el-option label="上下限" :value="3" />
  286. <el-option label="规格" :value="4" />
  287. <el-option label="时间" :value="5" />
  288. <el-option label="范围" :value="6" />
  289. <el-option label="文本" :value="7" />
  290. <!-- <el-option label="枚举" :value="8" /> -->
  291. </el-select>
  292. </template>
  293. <template v-slot:paramValue="{ row }">
  294. <!-- 根据参数类型渲染不同的输入组件 -->
  295. <el-link
  296. v-if="formData.classify == '4'"
  297. :underline="false"
  298. style="cursor: pointer"
  299. >
  300. <div class="ele-cell">
  301. <div @click="selectChooseModalProduct(row)">
  302. {{ row.productName ? row.productName : '请选择产品' }}
  303. </div>
  304. <i
  305. v-if="row.tools.length == 0"
  306. class="el-icon-arrow-down"
  307. @click="selectChooseModalProduct(row)"
  308. ></i>
  309. <i v-else class="el-icon-close" @click="clearProduct(row)"></i>
  310. </div>
  311. </el-link>
  312. <el-input
  313. v-else
  314. v-model="row.paramValue"
  315. placeholder="请输入参数内容"
  316. size="mini"
  317. type="textarea"
  318. rows="1"
  319. autosize
  320. ></el-input>
  321. </template>
  322. <template v-slot:defaultValue="{ row }">
  323. <el-row>
  324. <el-col :span="12">
  325. <!-- <el-select
  326. v-if="row.paramType != 7"
  327. v-model="row.symbol"
  328. placeholder="请选择"
  329. size="mini"
  330. >
  331. <el-option label=">" value=">"> </el-option>
  332. <el-option label="<" value="<"> </el-option>
  333. <el-option label="!=" value="!="> </el-option>
  334. <el-option label=">=" value=">="> </el-option>
  335. <el-option label="<=" value="<="> </el-option>
  336. <el-option label="~~" value="~~"> </el-option>
  337. <el-option label="+-" value="+-"> </el-option>
  338. <el-option label="......" value="......"> </el-option>
  339. </el-select> -->
  340. <DictSelection
  341. v-if="row.paramType != 7"
  342. clearable
  343. dictName="数学字符"
  344. v-model="row.symbol"
  345. placeholder="请选择逻辑"
  346. size="mini"
  347. ></DictSelection>
  348. </el-col>
  349. <el-col :span="row.paramType != 7 ? 12 : 24">
  350. <el-input
  351. v-model="row.defaultValue"
  352. placeholder="请输入默认值"
  353. size="mini"
  354. ></el-input>
  355. </el-col>
  356. </el-row>
  357. </template>
  358. <template v-slot:maxValue="{ row }">
  359. <el-input
  360. v-if="row.paramType == 3 || row.paramType == 6"
  361. v-model="row.maxValue"
  362. placeholder="请输入参数上限"
  363. size="mini"
  364. ></el-input>
  365. </template>
  366. <template v-slot:minValue="{ row }">
  367. <el-input
  368. v-if="row.paramType == 3 || row.paramType == 6"
  369. v-model="row.minValue"
  370. placeholder="请输入参数下限"
  371. size="mini"
  372. ></el-input>
  373. </template>
  374. <template v-slot:unitName="{ row }">
  375. <!-- <el-input
  376. v-model="row.unitName"
  377. placeholder="请输入参数单位"
  378. size="mini"
  379. ></el-input> -->
  380. <DictSelection
  381. v-if="row.paramType != 7"
  382. dictName="工艺参数单位"
  383. clearable
  384. filterable
  385. v-model="row.unitName"
  386. size="mini"
  387. >
  388. </DictSelection>
  389. </template>
  390. <template v-slot:toolName="{ row }">
  391. <el-link :underline="false" style="cursor: pointer">
  392. <div class="ele-cell">
  393. <div @click="handleAdd(row)">
  394. {{
  395. row.tools && row.tools.length > 0
  396. ? row.tools.map((i) => i.toolName).join(',')
  397. : '请选择'
  398. }}
  399. </div>
  400. <i
  401. v-if="row.tools.length == 0"
  402. class="el-icon-arrow-down"
  403. @click="handleAdd(row)"
  404. ></i>
  405. <i v-else class="el-icon-close" @click="clearTool(row)"></i>
  406. </div>
  407. </el-link>
  408. </template>
  409. <template v-slot:toolCodes="{ row }">
  410. <el-input
  411. :value="
  412. row.tools && row.tools.length > 0
  413. ? row.tools.map((i) => i.toolCode).join(',')
  414. : ''
  415. "
  416. placeholder="工具自动带出"
  417. disabled
  418. size="mini"
  419. ></el-input>
  420. </template>
  421. <template v-slot:remark="{ row }">
  422. <el-input
  423. v-model="row.remark"
  424. placeholder="请输入"
  425. size="mini"
  426. ></el-input>
  427. </template>
  428. <template v-slot:executeMethodTitle="{ row }">
  429. <el-select v-model="row.executeMethodTitle" clearable size="mini">
  430. <el-option
  431. v-for="item in formData.executeMethodList"
  432. :key="item"
  433. :label="item"
  434. :value="item"
  435. ></el-option>
  436. </el-select>
  437. </template>
  438. <template v-slot:action="{ row }">
  439. <el-link
  440. type="danger"
  441. :underline="false"
  442. icon="el-icon-delete"
  443. @click="deleteRow(row)"
  444. >
  445. 删除
  446. </el-link>
  447. </template>
  448. </ele-pro-table>
  449. </el-form>
  450. <template v-slot:footer>
  451. <el-button
  452. v-if="type != 'detail'"
  453. :loading="btnLoading"
  454. type="primary"
  455. @click="saveAndPublish"
  456. >
  457. 保存并发布
  458. </el-button>
  459. <el-button
  460. v-if="type != 'detail'"
  461. :loading="btnLoading"
  462. type="primary"
  463. @click="confirm"
  464. >
  465. 保存
  466. </el-button>
  467. <el-button :loading="btnLoading" @click="handleClose">取消</el-button>
  468. </template>
  469. <toolModal ref="toolModalRef" @chooseModal="chooseModal" />
  470. <toolModal ref="toolModalTowRef" @chooseModal="chooseModalProduct" />
  471. <MaterialAdd
  472. ref="deviceSelectDialog"
  473. selectType="single"
  474. @chooseEquipment="chooseEquipment"
  475. />
  476. <ProductModal
  477. ref="ProductModalRef"
  478. @changeProduct="changeProduct"
  479. ></ProductModal>
  480. <ProductModal
  481. ref="ProductModalCorrelationRef"
  482. @changeProduct="changeRelateProduct"
  483. multiple
  484. ></ProductModal>
  485. <processModal
  486. ref="processModalRef"
  487. @chooseProcess="processChooseProcess"
  488. ></processModal>
  489. </ele-modal>
  490. </template>
  491. <script>
  492. import { getByCode } from '@/api/system/dictionary-data';
  493. // import RuleCycle from '../../matterRules/components/rule-cycle.vue';
  494. import RuleCycle from './rule-cycle.vue';
  495. import OperationGuideDialog from '@/views/rulesManagement/matterRules/components/operationGuideDialog.vue';
  496. import Details from './details.vue';
  497. import dictMixins from '@/mixins/dictMixins';
  498. import toolModal from './toolModal.vue';
  499. import MaterialAdd from '../../components/MaterialAdd.vue';
  500. import {
  501. recordrulesSave,
  502. recordrulesDetailPage,
  503. recordrulesUpdate,
  504. recordrulesPublish,
  505. recordrulesSaveAndPublish,
  506. recordrulesUpdateVersion,
  507. recordrulesCyclePage,
  508. recordrulesGetById
  509. } from '@/api/recordrules/index';
  510. import ProductModal from '@/components/selectProduct/ProductModal.vue';
  511. import { getTreeByPid } from '@/api/classifyManage';
  512. import processModal from './processModal.vue';
  513. export default {
  514. components: {
  515. OperationGuideDialog,
  516. RuleCycle,
  517. Details,
  518. ProductModal,
  519. MaterialAdd,
  520. toolModal,
  521. processModal
  522. },
  523. mixins: [dictMixins],
  524. computed: {
  525. bankColumns() {
  526. return [
  527. {
  528. width: 110,
  529. type: 'index',
  530. columnKey: 'index',
  531. align: 'center',
  532. label: '序号'
  533. },
  534. {
  535. prop: 'paramType',
  536. label: '参数类型',
  537. align: 'center',
  538. slot: 'paramType',
  539. minWidth: 110
  540. },
  541. {
  542. prop: 'paramValue',
  543. label: '参数内容',
  544. align: 'center',
  545. slot: 'paramValue',
  546. minWidth: 261
  547. },
  548. {
  549. prop: 'defaultValue',
  550. label: '默认值',
  551. align: 'center',
  552. slot: 'defaultValue',
  553. minWidth: 150
  554. },
  555. {
  556. prop: 'maxValue',
  557. label: '参数上限',
  558. align: 'center',
  559. slot: 'maxValue',
  560. minWidth: 110
  561. },
  562. {
  563. prop: 'minValue',
  564. label: '参数下限',
  565. align: 'center',
  566. slot: 'minValue',
  567. minWidth: 110
  568. },
  569. {
  570. prop: 'unitName',
  571. label: '参数单位',
  572. align: 'center',
  573. slot: 'unitName',
  574. minWidth: 110
  575. },
  576. {
  577. prop: 'toolName',
  578. label: '工具名称',
  579. align: 'center',
  580. slot: 'toolName',
  581. minWidth: 110
  582. },
  583. {
  584. prop: 'toolCodes',
  585. label: '工具编码',
  586. align: 'center',
  587. slot: 'toolCodes',
  588. minWidth: 110
  589. },
  590. {
  591. prop: 'remark',
  592. label: '备注',
  593. align: 'center',
  594. slot: 'remark',
  595. minWidth: 110
  596. },
  597. {
  598. prop: 'executeMethodTitle',
  599. label: '执行方式',
  600. align: 'center',
  601. slot: 'executeMethodTitle',
  602. minWidth: 180
  603. },
  604. {
  605. columnKey: 'action',
  606. label: '操作',
  607. width: 110,
  608. align: 'center',
  609. resizable: false,
  610. slot: 'action',
  611. fixed: 'right'
  612. }
  613. ];
  614. },
  615. versionText() {
  616. if (this.type == 'clone') {
  617. return '系统自动生成';
  618. }
  619. return (
  620. this.formData.bigVersion +
  621. this.formData.versionMark +
  622. this.formData.smallVersion
  623. );
  624. },
  625. productColumns() {
  626. return [
  627. {
  628. columnKey: 'index',
  629. type: 'index',
  630. width: 45,
  631. align: 'center',
  632. reserveSelection: true
  633. },
  634. {
  635. prop: 'code',
  636. label: '产品编码'
  637. },
  638. {
  639. prop: 'name',
  640. label: '产品名称',
  641. showOverflowTooltip: true
  642. },
  643. {
  644. prop: 'brandNum',
  645. label: '牌号'
  646. },
  647. {
  648. prop: 'modelType',
  649. label: '型号'
  650. },
  651. {
  652. prop: 'measuringUnit',
  653. label: '计量单位'
  654. },
  655. {
  656. prop: 'packingUnit',
  657. label: '包装单位'
  658. },
  659. {
  660. columnKey: 'action',
  661. label: '操作',
  662. width: 110,
  663. align: 'center',
  664. resizable: false,
  665. slot: 'action',
  666. fixed: 'right'
  667. }
  668. ];
  669. },
  670. cacheKeyUrl() {
  671. return `main-permit-add-2510181429-reportWorkType`;
  672. },
  673. detailsList() {
  674. if (this.formData.isExecuteMethod) {
  675. return this.formData.details.filter(
  676. (i) => i.executeMethodTitle == this.formData.executeMethodTitle
  677. );
  678. } else {
  679. return this.formData.details;
  680. }
  681. }
  682. },
  683. data() {
  684. const formDateBase = {
  685. id: null,
  686. classify: null,
  687. deviceId: null,
  688. deviceName: '',
  689. frequencyUnit: 2,
  690. frequencyValue: null,
  691. name: '',
  692. details: [],
  693. recordRulesCycleList: [],
  694. startDate: null,
  695. stopDate: null,
  696. version: 1,
  697. code: '',
  698. fromId: null,
  699. // 模块分类 参考字典项:record_rules_report_work_type
  700. reportWorkType: '1',
  701. // 关联产品方式,0-不关联,1-关联分类,2-关联产品
  702. relateProductMethod: 0,
  703. // 关联分类
  704. categoryLevels: [],
  705. // 关联产品
  706. categories: [],
  707. // 执行方式
  708. isExecuteMethod: 0,
  709. produceTaskConfigs: [],
  710. // 关联工序
  711. produceTaskConfigBatchSavePo: {
  712. addPOs: [],
  713. deletedIds: [],
  714. produceTaskId: '',
  715. produceTaskName: '',
  716. updatePOs: []
  717. },
  718. // 执行方式列表
  719. executeMethodList: [],
  720. // 执行方式 活跃项
  721. executeMethodTitle: '',
  722. bigVersion: '',
  723. versionMark: '',
  724. smallVersion: ''
  725. };
  726. return {
  727. dialogTitle: '',
  728. visible: false,
  729. formDateBase,
  730. formData: JSON.parse(JSON.stringify(formDateBase)),
  731. formRules: {
  732. name: [
  733. { required: true, message: '请输入规则名称', trigger: 'blur' }
  734. ],
  735. frequencyValue: [
  736. { required: true, message: '请选择周期', trigger: 'blur' },
  737. { required: true, message: '请选择周期', trigger: 'change' }
  738. ],
  739. frequencyUnit: [
  740. { required: true, message: '请选择频率单位', trigger: 'change' }
  741. ],
  742. classify: [
  743. { required: true, message: '请选择规则类型', trigger: 'change' }
  744. ],
  745. // startDate 启用日期要大于当前时间
  746. // stopDate 停用时间要大于当前时间并且大于启用日期
  747. startDate: [
  748. { required: true, message: '请选择启用日期', trigger: 'blur' },
  749. { required: true, message: '请选择启用日期', trigger: 'change' },
  750. { validator: this.validateStartDate, trigger: 'change' }
  751. ],
  752. stopDate: [
  753. { required: true, message: '请选择停用时间', trigger: 'change' },
  754. { validator: this.validateStopDate, trigger: 'change' }
  755. ],
  756. deviceName: [
  757. { required: true, message: '请输入选择设备', trigger: 'blur' }
  758. ],
  759. reportWorkType: [
  760. { required: true, message: '请选择模块分类', trigger: 'change' },
  761. { required: true, message: '请选择模块分类', trigger: 'blur' }
  762. ],
  763. categoryLevels: [
  764. {
  765. required: true,
  766. message: '请选择关联产品分类',
  767. trigger: 'change'
  768. },
  769. { required: true, message: '请选择关联产品分类', trigger: 'blur' }
  770. ]
  771. },
  772. recordSheet: [], // 记录表
  773. current: {},
  774. dataIndex: null,
  775. showEdit: false,
  776. btnLoading: false,
  777. currentRow: null,
  778. type: '',
  779. relateProductMethodOpeions: [
  780. { label: '不关联', value: 0 },
  781. // { label: '关联分类', value: 1 },
  782. { label: '关联产品', value: 2 }
  783. ],
  784. // 产品分类
  785. productCategory: [],
  786. loading: false
  787. };
  788. },
  789. mounted() {
  790. this.getByCodeData();
  791. this.getProductCategory();
  792. console.log('this.formData 2233', this.formData);
  793. },
  794. methods: {
  795. open(row, type, title) {
  796. this.dialogTitle = title;
  797. this.type = type;
  798. console.log('type', type, row);
  799. if (type == 'edit' || type == 'detail') {
  800. this.getDetils(row.id);
  801. }
  802. if (type == 'clone') {
  803. this.getDetils(row.id);
  804. }
  805. if (type == 'add') {
  806. this.formData.version = 1;
  807. // 启用日期 默认为 今天
  808. this.formData.startDate = new Date();
  809. // 停用日期 默认为 2099-12-31
  810. this.formData.stopDate = new Date('2099-12-31 00:00:00');
  811. }
  812. this.visible = true;
  813. console.log('this.formData', this.formData);
  814. },
  815. async getDetils(id) {
  816. this.loading = true;
  817. try {
  818. const data = await recordrulesGetById(id);
  819. if (data.relateProductMethod == 1) {
  820. data.categoryLevels = data.produceTaskConfigs
  821. .map((i) => i.categoryLevelId)
  822. .filter((i) => i != null);
  823. } else {
  824. data.categoryLevels = [];
  825. }
  826. if (data.relateProductMethod == 2) {
  827. // 产品
  828. data.categories = data.produceTaskConfigs.map((i) => {
  829. return {
  830. id: i.productId,
  831. code: i.productCode,
  832. name: i.productName,
  833. brandNum: i.brandNum,
  834. modelType: i.modelType,
  835. measuringUnit: i.measuringUnit,
  836. packingUnit: i.packingUnit
  837. };
  838. });
  839. } else {
  840. data.categories = [];
  841. }
  842. data.produceTaskConfigBatchSavePo = {
  843. addPOs: [],
  844. deletedIds: [],
  845. produceTaskId: data.produceTaskConfigs[0]?.produceTaskId,
  846. produceTaskName: data.produceTaskConfigs[0]?.produceTaskName,
  847. updatePOs: []
  848. };
  849. if (data.isExecuteMethod) {
  850. data.executeMethodList = Object.keys(data.detailMap).map((i) => {
  851. return i === '' ? '无执行方式' : i;
  852. });
  853. if (data.executeMethodList.includes('无执行方式')) {
  854. // 将无执行方式 放到第一个
  855. data.executeMethodList = data.executeMethodList.filter(
  856. (i) => i !== '无执行方式'
  857. );
  858. data.executeMethodList.unshift('无执行方式');
  859. } else {
  860. // 添加一个 无执行方式
  861. data.executeMethodList.unshift('无执行方式');
  862. }
  863. data.details = Object.values(data.detailMap)
  864. .flat()
  865. .map((i) => {
  866. if (i.executeMethodTitle == '') {
  867. i.executeMethodTitle = '无执行方式';
  868. }
  869. return i;
  870. });
  871. data.executeMethodTitle = data.executeMethodList[0] || '';
  872. } else {
  873. data.executeMethodList = [];
  874. data.details = data.details || [];
  875. data.executeMethodTitle = '';
  876. }
  877. this.$util.assignObject(this.formData, data);
  878. this.$nextTick(() => {
  879. this.$refs.cycleMultipleRef?.setRecordRulesCycleList(
  880. this.formData.recordRulesCycleList
  881. );
  882. });
  883. this.formData.startDate = new Date(data.startDate);
  884. this.formData.stopDate = new Date(data.stopDate);
  885. this.formData.classify = this.formData.classify + '';
  886. this.formData.reportWorkType = this.formData.reportWorkType + '';
  887. if (this.type == 'clone') {
  888. this.formData.name = this.formData.name + '-副本';
  889. this.formData.fromId = id;
  890. this.formData.id = null;
  891. }
  892. this.loading = false;
  893. } catch (error) {
  894. this.loading = false;
  895. }
  896. },
  897. async getByCodeData() {
  898. let res = await getByCode('record_sheet');
  899. let list = res.data.map((item) => {
  900. let values = Object.keys(item);
  901. return {
  902. value: values[0],
  903. label: item[values[0]]
  904. };
  905. });
  906. this.recordSheet = list;
  907. },
  908. itemDel(index) {
  909. this.formData.details.splice(index, 1);
  910. },
  911. /* 打开操作手册编辑款 */
  912. openOperationGuideDialogDialog(row, index) {
  913. this.$refs.operationGuideDialog.open(row, index);
  914. },
  915. handleClose() {
  916. // 清空表单数据
  917. this.formData = JSON.parse(JSON.stringify(this.formDateBase));
  918. this.$refs['formRef'].resetFields();
  919. this.visible = false;
  920. },
  921. // 保存
  922. confirm() {
  923. console.log('this.formData', this.formData);
  924. // 验证表单规则
  925. this.$refs.formRef.validate(async (valid) => {
  926. if (!valid) {
  927. return false;
  928. }
  929. if (this.formData.details.length == 0) {
  930. return this.$message.warning('至少条件一条规则项');
  931. }
  932. if (this.formData.isExecuteMethod) {
  933. // 判断 formData.executeMethodList中的item 是否在details中有一条executeMethodTitle的数据
  934. if (this.formData.executeMethodList.length == 0) {
  935. return this.$message.warning(`请添加执行方式`);
  936. }
  937. for (const item of this.formData.executeMethodList) {
  938. const exists = this.formData.details.some(
  939. (detail) => detail.executeMethodTitle === item
  940. );
  941. if (!exists) {
  942. this.$message.warning(
  943. `请为执行方式 "${item}" 添加至少一条规则项`
  944. );
  945. return false;
  946. }
  947. }
  948. }
  949. if (this.formData.relateProductMethod == 2) {
  950. // 关联产品
  951. if (this.formData.categories.length == 0) {
  952. return this.$message.warning('请选择关联产品');
  953. }
  954. }
  955. try {
  956. this.btnLoading = true;
  957. const body = this.formatBody();
  958. if (this.type == 'add') {
  959. await recordrulesSave(body);
  960. } else if (this.type == 'clone') {
  961. await recordrulesUpdateVersion(body);
  962. } else {
  963. // 编辑
  964. body.fromId = null;
  965. await recordrulesUpdate(body);
  966. }
  967. this.btnLoading = false;
  968. this.$message.success('操作成功');
  969. this.handleClose();
  970. this.$emit('reload');
  971. } catch (error) {
  972. this.btnLoading = false;
  973. }
  974. });
  975. },
  976. // 保存并发布
  977. saveAndPublish() {
  978. // 验证表单规则
  979. this.$refs.formRef.validate(async (valid) => {
  980. if (!valid) {
  981. return false;
  982. }
  983. if (this.formData.details.length == 0) {
  984. return this.$message.warning('至少条件一条规则项');
  985. }
  986. if (this.formData.isExecuteMethod) {
  987. // 判断 formData.executeMethodList中的item 是否在details中有一条executeMethodTitle的数据
  988. if (this.formData.executeMethodList.length == 0) {
  989. return this.$message.warning(`请添加执行方式`);
  990. }
  991. for (const item of this.formData.executeMethodList) {
  992. const exists = this.formData.details.some(
  993. (detail) => detail.executeMethodTitle === item
  994. );
  995. if (!exists) {
  996. this.$message.warning(
  997. `请为执行方式 "${item}" 添加至少一条规则项`
  998. );
  999. return false;
  1000. }
  1001. }
  1002. }
  1003. if (this.formData.relateProductMethod == 2) {
  1004. // 关联产品
  1005. if (this.formData.categories.length == 0) {
  1006. return this.$message.warning('请选择关联产品');
  1007. }
  1008. }
  1009. try {
  1010. this.btnLoading = true;
  1011. const body = this.formatBody();
  1012. await recordrulesSaveAndPublish(body);
  1013. this.btnLoading = false;
  1014. this.$message.success('操作成功');
  1015. this.handleClose();
  1016. this.$emit('reload');
  1017. } catch (error) {
  1018. this.btnLoading = false;
  1019. }
  1020. });
  1021. },
  1022. // 数据格式化
  1023. formatBody() {
  1024. this.formData.recordRulesCycleList =
  1025. this.$refs.cycleMultipleRef.recordRulesCycleList
  1026. .map((i) => {
  1027. // 根据月日时分排序计算权重排序
  1028. let sortNum = 0;
  1029. if (i.month) {
  1030. sortNum += i.month * 60 * 24 * 30;
  1031. }
  1032. if (i.day) {
  1033. sortNum += i.day * 60 * 24;
  1034. }
  1035. if (i.hour) {
  1036. sortNum += i.hour * 60;
  1037. }
  1038. if (i.minute) {
  1039. sortNum += i.minute * 1;
  1040. }
  1041. return { ...i, sortNum };
  1042. })
  1043. .sort((a, b) => a.sortNum - b.sortNum)
  1044. .map((i, index) => {
  1045. return { ...i, sortNum: index + 1 };
  1046. });
  1047. const body = JSON.parse(JSON.stringify(this.formData));
  1048. body.details = body.details.map((i) => {
  1049. if (i.executeMethodTitle == '无执行方式') {
  1050. i.executeMethodTitle = '';
  1051. }
  1052. return i;
  1053. });
  1054. body.startDate = this.$util.toDateString(
  1055. body.startDate,
  1056. 'yyyy-MM-dd HH:mm:ss'
  1057. );
  1058. body.stopDate = this.$util.toDateString(
  1059. body.stopDate,
  1060. 'yyyy-MM-dd HH:mm:ss'
  1061. );
  1062. if (this.type == 'edit') {
  1063. if (body.produceTaskConfigBatchSavePo.produceTaskId) {
  1064. // 修改工序
  1065. if (body.relateProductMethod == 1) {
  1066. // 分类
  1067. body.categoryLevels.forEach((categoryId) => {
  1068. // 判断是否已经存在
  1069. const exist = body.produceTaskConfigs.find(
  1070. (i) => i.categoryLevelId == categoryId
  1071. );
  1072. if (!exist) {
  1073. body.produceTaskConfigBatchSavePo.addPOs.push({
  1074. executeMethod: 2,
  1075. itemType: 1,
  1076. produceTaskId:
  1077. body.produceTaskConfigBatchSavePo.produceTaskId,
  1078. produceTaskName:
  1079. body.produceTaskConfigBatchSavePo.produceTaskName,
  1080. categoryLevelId: categoryId,
  1081. reportWorkType: this.formData.reportWorkType
  1082. });
  1083. }
  1084. });
  1085. // 删除取消的分类
  1086. body.produceTaskConfigs.forEach((config) => {
  1087. if (
  1088. !body.categoryLevels.includes(config.categoryLevelId) &&
  1089. config.id
  1090. ) {
  1091. body.produceTaskConfigBatchSavePo.deletedIds.push(config.id);
  1092. }
  1093. });
  1094. }
  1095. if (body.relateProductMethod == 2) {
  1096. // 产品
  1097. body.categories.forEach((product) => {
  1098. // 判断是否已经存在
  1099. const exist = body.produceTaskConfigs.find(
  1100. (i) => i.productId == product.id
  1101. );
  1102. if (!exist) {
  1103. body.produceTaskConfigBatchSavePo.addPOs.push({
  1104. executeMethod: 2,
  1105. itemType: 2,
  1106. produceTaskId:
  1107. body.produceTaskConfigBatchSavePo.produceTaskId,
  1108. produceTaskName:
  1109. body.produceTaskConfigBatchSavePo.produceTaskName,
  1110. productCode: product.code,
  1111. productId: product.id || product.productId,
  1112. productName: product.name || product.productName,
  1113. reportWorkType: this.formData.reportWorkType
  1114. });
  1115. }
  1116. });
  1117. // 删除取消的产品
  1118. body.produceTaskConfigs.forEach((config) => {
  1119. const exist = body.categories.find((product) => {
  1120. return product.id == config.productId;
  1121. });
  1122. if (!exist && config.id) {
  1123. body.produceTaskConfigBatchSavePo.deletedIds.push(config.id);
  1124. }
  1125. });
  1126. }
  1127. if (body.relateProductMethod == 0) {
  1128. // 不关联产品 但存在工序
  1129. // 判断是否已经存在
  1130. const item = body.produceTaskConfigs.find(
  1131. (i) =>
  1132. i.produceTaskId ==
  1133. body.produceTaskConfigBatchSavePo.produceTaskId
  1134. );
  1135. if (item) {
  1136. // 修改
  1137. body.produceTaskConfigBatchSavePo.updatePOs.push({
  1138. ...item,
  1139. produceTaskId:
  1140. body.produceTaskConfigBatchSavePo.produceTaskId,
  1141. produceTaskName:
  1142. body.produceTaskConfigBatchSavePo.produceTaskName,
  1143. reportWorkType: this.formData.reportWorkType
  1144. });
  1145. } else {
  1146. // 新增
  1147. body.produceTaskConfigBatchSavePo.deletedIds =
  1148. this.formData.produceTaskConfigs.map((i) => i.id);
  1149. body.produceTaskConfigBatchSavePo.addPOs.push({
  1150. executeMethod: 2,
  1151. itemType: 2,
  1152. produceTaskId:
  1153. body.produceTaskConfigBatchSavePo.produceTaskId,
  1154. produceTaskName:
  1155. body.produceTaskConfigBatchSavePo.produceTaskName,
  1156. reportWorkType: this.formData.reportWorkType
  1157. });
  1158. }
  1159. }
  1160. } else {
  1161. // 删除工序 全删
  1162. body.produceTaskConfigBatchSavePo.deletedIds =
  1163. this.formData.produceTaskConfigs.map((i) => i.id);
  1164. }
  1165. } else {
  1166. // 新增工序
  1167. if (
  1168. body.reportWorkType != 0 &&
  1169. body.produceTaskConfigBatchSavePo.produceTaskId
  1170. ) {
  1171. if (body.relateProductMethod == 1) {
  1172. // 分类
  1173. body.categoryLevels.forEach((categoryId) => {
  1174. body.produceTaskConfigBatchSavePo.addPOs.push({
  1175. executeMethod: 2,
  1176. itemType: 1,
  1177. produceTaskId:
  1178. body.produceTaskConfigBatchSavePo.produceTaskId,
  1179. produceTaskName:
  1180. body.produceTaskConfigBatchSavePo.produceTaskName,
  1181. categoryLevelId: categoryId,
  1182. reportWorkType: this.formData.reportWorkType
  1183. });
  1184. });
  1185. }
  1186. if (body.relateProductMethod == 2) {
  1187. // 产品
  1188. body.categories.forEach((product) => {
  1189. body.produceTaskConfigBatchSavePo.addPOs.push({
  1190. executeMethod: 2,
  1191. itemType: 2,
  1192. produceTaskId:
  1193. body.produceTaskConfigBatchSavePo.produceTaskId,
  1194. produceTaskName:
  1195. body.produceTaskConfigBatchSavePo.produceTaskName,
  1196. productCode: product.code,
  1197. productId: product.id || product.productId,
  1198. productName: product.name || product.productName,
  1199. reportWorkType: this.formData.reportWorkType
  1200. });
  1201. });
  1202. }
  1203. if (body.relateProductMethod == 0) {
  1204. // 不关联
  1205. body.produceTaskConfigBatchSavePo.addPOs.push({
  1206. executeMethod: 2,
  1207. itemType: 2,
  1208. produceTaskId: body.produceTaskConfigBatchSavePo.produceTaskId,
  1209. produceTaskName:
  1210. body.produceTaskConfigBatchSavePo.produceTaskName,
  1211. reportWorkType: this.formData.reportWorkType
  1212. });
  1213. }
  1214. }
  1215. body.produceTaskConfigBatchSavePo.updatePOs = [];
  1216. }
  1217. return body;
  1218. },
  1219. // startDate 启用日期要大于当前时间
  1220. validateStartDate(rule, value, callback) {
  1221. const startDate = this.formData.startDate;
  1222. if (!startDate) {
  1223. return callback(new Error('启用日期不能为空'));
  1224. }
  1225. // 启用日期大于等于今天
  1226. // const today = new Date();
  1227. // today.setHours(0, 0, 0, 0); // 设置为当天的开始时间
  1228. // if (new Date(startDate) < today) {
  1229. // return callback(new Error('启用日期必须大于等于当前日期'));
  1230. // }
  1231. callback();
  1232. },
  1233. // stopDate 停用时间要大于当前时间并且大于启用日期
  1234. validateStopDate(rule, value, callback) {
  1235. const startDate = this.formData.startDate;
  1236. const stopDate = this.formData.stopDate;
  1237. if (
  1238. stopDate &&
  1239. startDate &&
  1240. new Date(stopDate) <= new Date(startDate)
  1241. ) {
  1242. return callback(new Error('停用时间必须大于启用日期'));
  1243. }
  1244. callback();
  1245. },
  1246. // 去选择设备
  1247. selectDeviceId() {
  1248. this.$refs.deviceSelectDialog.open([]);
  1249. },
  1250. // 选择设备回调
  1251. chooseEquipment(data, index, categoryId) {
  1252. console.log('data', data, index, categoryId);
  1253. this.formData.deviceId = data[0]?.id || null;
  1254. this.formData.deviceName = data[0]?.name || '';
  1255. },
  1256. // 添加
  1257. addRow() {
  1258. this.formData.details.push({
  1259. id: new Date().getTime(),
  1260. defaultValue: '',
  1261. maxValue: null,
  1262. minValue: null,
  1263. paramType: null,
  1264. paramValue: null,
  1265. remark: '',
  1266. symbol: null,
  1267. tools: [],
  1268. unitName: null,
  1269. productName: '',
  1270. productCode: '',
  1271. executeMethodTitle: this.formData.executeMethodTitle
  1272. });
  1273. console.log('this.formData.details', this.formData.details);
  1274. },
  1275. deleteRow(row) {
  1276. const index = this.formData.details.indexOf(row);
  1277. if (index !== -1) {
  1278. this.formData.details.splice(index, 1);
  1279. }
  1280. },
  1281. // 删除关联产品
  1282. productColumnsDeleteRow(row) {
  1283. this.formData.categories = this.formData.categories.filter((i) => {
  1284. return i.id !== row.id;
  1285. });
  1286. },
  1287. handleAdd(row) {
  1288. this.currentRow = row;
  1289. this.$refs.toolModalRef.open(row.toolCodes);
  1290. },
  1291. chooseModal(data) {
  1292. console.log('data', data);
  1293. this.currentRow.tools = data.map((i) => {
  1294. return {
  1295. toolCode: i.code,
  1296. toolName: i.name
  1297. // rulesDetailId: this.currentRow.id,
  1298. // rulesId: this.formData.id
  1299. };
  1300. });
  1301. },
  1302. // 规则明细表
  1303. async recordrulesDetailPage(row) {
  1304. const { list } = await recordrulesDetailPage({
  1305. // deptId: row.deptId,
  1306. pageNum: 1,
  1307. rulesId: row.id,
  1308. size: 9999
  1309. });
  1310. console.log('list 数据', list);
  1311. this.formData.details = list;
  1312. },
  1313. // 清空工具
  1314. clearTool(row) {
  1315. row.tools = [];
  1316. },
  1317. // 查询 recordrulesCyclePage
  1318. async recordrulesCyclePage(row) {
  1319. const { list } = await recordrulesCyclePage({
  1320. pageNum: 1,
  1321. size: 9999,
  1322. recordRulesId: row.id,
  1323. orderBy: 'descending'
  1324. });
  1325. console.log('list 周期数据', list);
  1326. this.formData.recordRulesCycleList = list;
  1327. this.$nextTick(() => {
  1328. this.$refs.cycleMultipleRef.setRecordRulesCycleList(list);
  1329. });
  1330. },
  1331. // 去选择产品
  1332. selectProduct(row) {
  1333. this.currentRow = row;
  1334. this.$refs.ProductModalRef.open();
  1335. },
  1336. // 选择产品
  1337. changeProduct(current) {
  1338. console.log('current', current);
  1339. this.currentRow.productName = current.name;
  1340. this.currentRow.productCode = current.code;
  1341. },
  1342. // 选择物品 产品、物料等
  1343. selectChooseModalProduct(row) {
  1344. this.currentRow = row;
  1345. this.$refs.toolModalTowRef.open([], '选择物品');
  1346. },
  1347. chooseModalProduct(current) {
  1348. console.log('current', current);
  1349. this.currentRow.productName = current[0].name;
  1350. this.currentRow.productCode = current[0].code;
  1351. console.log('this.currentRow', this.currentRow);
  1352. },
  1353. // 清空产品
  1354. clearProduct(row) {
  1355. row.productName = '';
  1356. row.productCode = '';
  1357. },
  1358. // 关联产品
  1359. relateProductSelect() {
  1360. this.$refs.ProductModalCorrelationRef.open();
  1361. },
  1362. changeRelateProduct(array) {
  1363. console.log('this.formData.categories ', array);
  1364. const productList = array.filter(
  1365. (i) => !this.formData.categories.some((cat) => cat.id === i.id)
  1366. );
  1367. this.formData.categories = [
  1368. ...this.formData.categories,
  1369. ...productList
  1370. ];
  1371. },
  1372. // 获取产品分类
  1373. async getProductCategory() {
  1374. let { data } = await getTreeByPid(9);
  1375. console.log('产品分类', data);
  1376. this.productCategory = data;
  1377. },
  1378. // 选择工序
  1379. openProduceTaskDialog() {
  1380. if (this.formData.produceTaskConfigs) {
  1381. // 其中包含 isUsing 为 true 则不能修改
  1382. const some = this.formData.produceTaskConfigs.some((i) => i.isUsing);
  1383. if (some) {
  1384. return this.$message.warning(
  1385. '当前规则关联的工序有执行中的记录,不能更改!'
  1386. );
  1387. }
  1388. }
  1389. this.$refs.processModalRef.open();
  1390. },
  1391. // 工序
  1392. processChooseProcess(process) {
  1393. console.log('选择的工序', process);
  1394. this.formData.produceTaskConfigBatchSavePo.produceTaskId = process.id;
  1395. this.formData.produceTaskConfigBatchSavePo.produceTaskName =
  1396. process.name;
  1397. },
  1398. // 添加执行方式
  1399. addExecuteMethod() {
  1400. this.$prompt('', '请输入执行方式', {
  1401. confirmButtonText: '确定',
  1402. cancelButtonText: '取消'
  1403. })
  1404. .then(({ value }) => {
  1405. if (this.formData.executeMethodList.includes(value)) {
  1406. return this.$message.warning('执行方式已存在!');
  1407. }
  1408. this.formData.executeMethodList.push(value);
  1409. if (this.formData.executeMethodList.length == 1) {
  1410. // 默认高亮
  1411. this.formData.executeMethodTitle = value;
  1412. }
  1413. })
  1414. .catch((err) => {});
  1415. },
  1416. // 删除执行方式
  1417. deleteExecuteMethod(item) {
  1418. // 如果this.formData.details总包含item 则不能删除
  1419. const exists = this.formData.details.some(
  1420. (detail) => detail.executeMethodTitle === item
  1421. );
  1422. if (exists) {
  1423. return this.$message.warning(
  1424. `执行方式 "${item}" 已被规则项使用,不能删除`
  1425. );
  1426. }
  1427. this.formData.executeMethodList =
  1428. this.formData.executeMethodList.filter((i) => i != item);
  1429. },
  1430. // 是否有执行方式改变
  1431. executeMethodChange() {
  1432. if (!this.formData.isExecuteMethod) {
  1433. this.formData.details = this.formData.details.map((i) => {
  1434. return {
  1435. ...i,
  1436. executeMethodTitle: '无执行方式'
  1437. };
  1438. });
  1439. } else {
  1440. if (this.formData.executeMethodList.length == 0) {
  1441. // 添加一个默认执行方式
  1442. this.formData.executeMethodList.push('无执行方式');
  1443. this.formData.details = this.formData.details.map((i) => {
  1444. return {
  1445. ...i,
  1446. executeMethodTitle: '无执行方式'
  1447. };
  1448. });
  1449. this.formData.executeMethodTitle = '无执行方式';
  1450. }
  1451. }
  1452. },
  1453. clearProductTask() {
  1454. // 如果有执行中的记录 则不能清空
  1455. if (
  1456. this.formData.produceTaskConfigs &&
  1457. this.formData.produceTaskConfigs[0] &&
  1458. this.formData.produceTaskConfigs[0].isUsing
  1459. ) {
  1460. return this.$message.warning(
  1461. '当前规则关联的工序有执行中的记录,不能更改!'
  1462. );
  1463. }
  1464. this.formData.produceTaskConfigBatchSavePo.produceTaskId = '';
  1465. this.formData.produceTaskConfigBatchSavePo.produceTaskName = '';
  1466. this.formData.relateProductMethod = 0;
  1467. this.formData.categoryLevels = [];
  1468. this.formData.categories = [];
  1469. }
  1470. }
  1471. };
  1472. </script>
  1473. <style scoped lang="scss">
  1474. .operationGuide_box {
  1475. width: 100%;
  1476. height: 48px;
  1477. display: flex;
  1478. overflow: hidden;
  1479. cursor: pointer;
  1480. box-sizing: border-box;
  1481. padding: 5px 10px;
  1482. .left_content {
  1483. width: 50%;
  1484. padding: 10px;
  1485. box-sizing: border-box;
  1486. border: 1px solid #c0c4cc;
  1487. border-radius: 10px;
  1488. margin-right: 10px;
  1489. overflow-y: auto;
  1490. }
  1491. .right_content {
  1492. flex: 1;
  1493. padding: 10px;
  1494. box-sizing: border-box;
  1495. border: 1px solid #c0c4cc;
  1496. border-radius: 10px;
  1497. overflow-y: auto;
  1498. }
  1499. }
  1500. ::v--deep .table_list {
  1501. .el-form-item {
  1502. .el-form-item__content {
  1503. margin-left: 0;
  1504. }
  1505. }
  1506. }
  1507. </style>