permitAdd.vue 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879
  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. >
  11. <el-form
  12. label-width="115px"
  13. :model="formData"
  14. :rules="formRules"
  15. ref="formRef"
  16. >
  17. <el-row style="margin-bottom: 10px">
  18. <el-col :span="8">
  19. <el-form-item label="记录规则类型" prop="classify" required>
  20. <el-select
  21. style="width: 100%"
  22. v-model="formData.classify"
  23. placeholder="请选择"
  24. >
  25. <el-option
  26. v-for="item in recordSheet"
  27. :key="item.value"
  28. :label="item.label"
  29. :value="item.value"
  30. >
  31. </el-option>
  32. </el-select>
  33. </el-form-item>
  34. </el-col>
  35. <el-col :span="8">
  36. <el-form-item label="记录规则编码" prop="code">
  37. <el-input
  38. v-model="formData.code"
  39. size="small"
  40. :disabled="true"
  41. placeholder="系统自动生成"
  42. ></el-input>
  43. </el-form-item>
  44. </el-col>
  45. <el-col :span="8">
  46. <el-form-item label="记录规则版本" prop="version">
  47. <el-input
  48. :value="versionText"
  49. size="small"
  50. disabled
  51. placeholder="系统自动生成"
  52. ></el-input>
  53. </el-form-item>
  54. </el-col>
  55. </el-row>
  56. <el-row style="margin-bottom: 10px">
  57. <el-col :span="8">
  58. <el-form-item label="记录规则名称" prop="name">
  59. <el-input
  60. v-model="formData.name"
  61. placeholder="请输入"
  62. size="small"
  63. ></el-input>
  64. </el-form-item>
  65. </el-col>
  66. <el-col :span="8">
  67. <el-form-item label="启用日期" required prop="startDate">
  68. <el-date-picker
  69. v-model="formData.startDate"
  70. type="date"
  71. placeholder="请选择启用日期"
  72. size="small"
  73. style="width: 100%"
  74. ></el-date-picker>
  75. </el-form-item>
  76. </el-col>
  77. <el-col :span="8">
  78. <el-form-item label="停用日期" required prop="stopDate">
  79. <el-date-picker
  80. v-model="formData.stopDate"
  81. type="date"
  82. placeholder="请选择停用日期"
  83. size="small"
  84. style="width: 100%"
  85. />
  86. </el-form-item>
  87. </el-col>
  88. <el-col v-if="formData.classify == 3" :span="8">
  89. <el-form-item label="关联设备" prop="deviceName" required>
  90. <el-input
  91. v-model="formData.deviceName"
  92. placeholder="请选择设备"
  93. size="small"
  94. :readonly="true"
  95. >
  96. <template #append>
  97. <el-button size="small" @click="selectDeviceId"
  98. >选择设备</el-button
  99. >
  100. </template>
  101. </el-input>
  102. </el-form-item>
  103. </el-col>
  104. </el-row>
  105. <el-row style="margin-bottom: 10px">
  106. <el-col :span="24">
  107. <el-form-item label="周期" prop="frequencyValue" required>
  108. <rule-cycle
  109. ref="cycleMultipleRef"
  110. :formData="formData"
  111. pageType="add"
  112. />
  113. </el-form-item>
  114. </el-col>
  115. </el-row>
  116. <ele-pro-table
  117. ref="table"
  118. :columns="bankColumns"
  119. :datasource="formData.recordRulesDetailList"
  120. :need-page="false"
  121. row-key="id"
  122. class="table_list"
  123. >
  124. <template v-slot:toolbar>
  125. <el-button
  126. size="small"
  127. type="primary"
  128. icon="el-icon-plus"
  129. class="ele-btn-icon"
  130. @click="addRow"
  131. >
  132. 新建
  133. </el-button>
  134. </template>
  135. <template v-slot:paramType="{ row }">
  136. <el-select
  137. v-model="row.paramType"
  138. placeholder="请选择参数类型"
  139. size="mini"
  140. required
  141. >
  142. <el-option label="数值" :value="1" />
  143. <el-option label="选择" :value="2" />
  144. <el-option label="上下限" :value="3" />
  145. <el-option label="规格" :value="4" />
  146. <el-option label="时间" :value="5" />
  147. <el-option label="范围" :value="6" />
  148. <el-option label="文本" :value="7" />
  149. <!-- <el-option label="枚举" :value="8" /> -->
  150. </el-select>
  151. </template>
  152. <template v-slot:paramValue="{ row }">
  153. <!-- 根据参数类型渲染不同的输入组件 -->
  154. <el-link
  155. v-if="formData.classify == '4'"
  156. :underline="false"
  157. style="cursor: pointer"
  158. >
  159. <div class="ele-cell">
  160. <div @click="selectProduct(row)">
  161. {{ row.productName ? row.productName : '请选择产品' }}
  162. </div>
  163. <i
  164. v-if="row.tools.length == 0"
  165. class="el-icon-arrow-down"
  166. @click="selectProduct(row)"
  167. ></i>
  168. <i v-else class="el-icon-close" @click="clearProduct(row)"></i>
  169. </div>
  170. </el-link>
  171. <el-input
  172. v-else
  173. v-model="row.paramValue"
  174. placeholder="请输入参数内容"
  175. size="mini"
  176. ></el-input>
  177. </template>
  178. <template v-slot:defaultValue="{ row }">
  179. <el-row>
  180. <el-col :span="12">
  181. <!-- <el-select
  182. v-if="row.paramType != 7"
  183. v-model="row.symbol"
  184. placeholder="请选择"
  185. size="mini"
  186. >
  187. <el-option label=">" value=">"> </el-option>
  188. <el-option label="<" value="<"> </el-option>
  189. <el-option label="!=" value="!="> </el-option>
  190. <el-option label=">=" value=">="> </el-option>
  191. <el-option label="<=" value="<="> </el-option>
  192. <el-option label="~~" value="~~"> </el-option>
  193. <el-option label="+-" value="+-"> </el-option>
  194. <el-option label="......" value="......"> </el-option>
  195. </el-select> -->
  196. <DictSelection
  197. v-if="row.paramType != 7"
  198. clearable
  199. dictName="数学字符"
  200. v-model="row.symbol"
  201. placeholder="请选择逻辑"
  202. size="mini"
  203. ></DictSelection>
  204. </el-col>
  205. <el-col :span="row.paramType != 7 ? 12 : 24">
  206. <el-input
  207. v-model="row.defaultValue"
  208. placeholder="请输入默认值"
  209. size="mini"
  210. ></el-input>
  211. </el-col>
  212. </el-row>
  213. </template>
  214. <template v-slot:maxValue="{ row }">
  215. <el-input
  216. v-if="row.paramType == 3 || row.paramType == 6"
  217. v-model="row.maxValue"
  218. placeholder="请输入参数上限"
  219. size="mini"
  220. ></el-input>
  221. </template>
  222. <template v-slot:minValue="{ row }">
  223. <el-input
  224. v-if="row.paramType == 3 || row.paramType == 6"
  225. v-model="row.minValue"
  226. placeholder="请输入参数下限"
  227. size="mini"
  228. ></el-input>
  229. </template>
  230. <template v-slot:unitName="{ row }">
  231. <!-- <el-input
  232. v-model="row.unitName"
  233. placeholder="请输入参数单位"
  234. size="mini"
  235. ></el-input> -->
  236. <DictSelection
  237. v-if="row.paramType != 7"
  238. dictName="工艺参数单位"
  239. clearable
  240. filterable
  241. v-model="row.unitName"
  242. size="mini"
  243. >
  244. </DictSelection>
  245. </template>
  246. <template v-slot:toolName="{ row }">
  247. <el-link :underline="false" style="cursor: pointer">
  248. <div class="ele-cell">
  249. <div @click="handleAdd(row)">
  250. {{
  251. row.tools && row.tools.length > 0
  252. ? row.tools.map((i) => i.toolName).join(',')
  253. : '请选择'
  254. }}
  255. </div>
  256. <i
  257. v-if="row.tools.length == 0"
  258. class="el-icon-arrow-down"
  259. @click="handleAdd(row)"
  260. ></i>
  261. <i v-else class="el-icon-close" @click="clearTool(row)"></i>
  262. </div>
  263. </el-link>
  264. </template>
  265. <template v-slot:toolCodes="{ row }">
  266. <el-input
  267. :value="
  268. row.tools && row.tools.length > 0
  269. ? row.tools.map((i) => i.toolCode).join(',')
  270. : ''
  271. "
  272. placeholder="工具自动带出"
  273. disabled
  274. size="mini"
  275. ></el-input>
  276. </template>
  277. <template v-slot:remark="{ row }">
  278. <el-input
  279. v-model="row.remark"
  280. placeholder="请输入"
  281. size="mini"
  282. ></el-input>
  283. </template>
  284. <template v-slot:action="{ row }">
  285. <el-link
  286. type="danger"
  287. :underline="false"
  288. icon="el-icon-delete"
  289. @click="deleteRow(row)"
  290. >
  291. 删除
  292. </el-link>
  293. </template>
  294. </ele-pro-table>
  295. </el-form>
  296. <template v-slot:footer>
  297. <el-button :loading="btnLoading" type="primary" @click="saveAndPublish">
  298. 保存并发布
  299. </el-button>
  300. <el-button :loading="btnLoading" type="primary" @click="confirm">
  301. 保存
  302. </el-button>
  303. <el-button :loading="btnLoading" @click="handleClose">取消</el-button>
  304. </template>
  305. <toolModal ref="toolModalRef" @chooseModal="chooseModal" />
  306. <MaterialAdd
  307. ref="deviceSelectDialog"
  308. selectType="single"
  309. @chooseEquipment="chooseEquipment"
  310. />
  311. <ProductModal
  312. ref="ProductModalRef"
  313. @changeProduct="changeProduct"
  314. ></ProductModal>
  315. </ele-modal>
  316. </template>
  317. <script>
  318. import { getByCode } from '@/api/system/dictionary-data';
  319. // import RuleCycle from '../../matterRules/components/rule-cycle.vue';
  320. import RuleCycle from './rule-cycle.vue';
  321. import OperationGuideDialog from '@/views/rulesManagement/matterRules/components/operationGuideDialog.vue';
  322. import Details from './details.vue';
  323. import dictMixins from '@/mixins/dictMixins';
  324. import toolModal from './toolModal.vue';
  325. import MaterialAdd from '../../components/MaterialAdd.vue';
  326. import {
  327. recordrulesSave,
  328. recordrulesDetailPage,
  329. recordrulesUpdate,
  330. recordrulesPublish,
  331. recordrulesSaveAndPublish,
  332. recordrulesUpdateVersion,
  333. recordrulesCyclePage
  334. } from '@/api/recordrules/index';
  335. import ProductModal from './ProductModal.vue';
  336. export default {
  337. components: {
  338. OperationGuideDialog,
  339. RuleCycle,
  340. Details,
  341. ProductModal,
  342. MaterialAdd,
  343. toolModal
  344. },
  345. mixins: [dictMixins],
  346. computed: {
  347. bankColumns() {
  348. return [
  349. {
  350. width: 110,
  351. type: 'index',
  352. columnKey: 'index',
  353. align: 'center',
  354. label: '序号'
  355. },
  356. {
  357. prop: 'paramType',
  358. label: '参数类型',
  359. align: 'center',
  360. slot: 'paramType',
  361. minWidth: 110
  362. },
  363. {
  364. prop: 'paramValue',
  365. label: '参数内容',
  366. align: 'center',
  367. slot: 'paramValue',
  368. minWidth: 180
  369. },
  370. {
  371. prop: 'defaultValue',
  372. label: '默认值',
  373. align: 'center',
  374. slot: 'defaultValue',
  375. minWidth: 150
  376. },
  377. {
  378. prop: 'maxValue',
  379. label: '参数上限',
  380. align: 'center',
  381. slot: 'maxValue',
  382. minWidth: 110
  383. },
  384. {
  385. prop: 'minValue',
  386. label: '参数下限',
  387. align: 'center',
  388. slot: 'minValue',
  389. minWidth: 110
  390. },
  391. {
  392. prop: 'unitName',
  393. label: '参数单位',
  394. align: 'center',
  395. slot: 'unitName',
  396. minWidth: 110
  397. },
  398. {
  399. prop: 'toolName',
  400. label: '工具名称',
  401. align: 'center',
  402. slot: 'toolName',
  403. minWidth: 110
  404. },
  405. {
  406. prop: 'toolCodes',
  407. label: '工具编码',
  408. align: 'center',
  409. slot: 'toolCodes',
  410. minWidth: 110
  411. },
  412. {
  413. prop: 'remark',
  414. label: '备注',
  415. align: 'center',
  416. slot: 'remark',
  417. minWidth: 110
  418. },
  419. {
  420. columnKey: 'action',
  421. label: '操作',
  422. width: 110,
  423. align: 'center',
  424. resizable: false,
  425. slot: 'action'
  426. }
  427. ];
  428. },
  429. versionText() {
  430. return this.formData.version
  431. ? `V${this.formData.version.toFixed(1)}`
  432. : 'V1.0';
  433. }
  434. },
  435. data() {
  436. return {
  437. dialogTitle: '',
  438. visible: false,
  439. formData: {
  440. id: null,
  441. classify: null,
  442. deviceId: null,
  443. deviceName: '',
  444. frequencyUnit: 2,
  445. frequencyValue: null,
  446. name: '',
  447. recordRulesDetailList: [
  448. {
  449. id: 0,
  450. defaultValue: '',
  451. maxValue: null,
  452. minValue: null,
  453. paramType: null,
  454. paramValue: null,
  455. remark: '',
  456. symbol: null,
  457. tools: [],
  458. unitName: null,
  459. productName: '',
  460. productCode: ''
  461. }
  462. ],
  463. recordRulesCycleList: [],
  464. startDate: null,
  465. stopDate: null,
  466. version: 1,
  467. code: '',
  468. fromId: null
  469. },
  470. formRules: {
  471. name: [
  472. { required: true, message: '请输入规则名称', trigger: 'blur' }
  473. ],
  474. frequencyValue: [
  475. { required: true, message: '请选择周期', trigger: 'blur' },
  476. { required: true, message: '请选择周期', trigger: 'change' }
  477. ],
  478. frequencyUnit: [
  479. { required: true, message: '请选择频率单位', trigger: 'change' }
  480. ],
  481. classify: [
  482. { required: true, message: '请选择规则类型', trigger: 'change' }
  483. ],
  484. // startDate 启用日期要大于当前时间
  485. // stopDate 停用时间要大于当前时间并且大于启用日期
  486. startDate: [
  487. { required: true, message: '请选择启用日期', trigger: 'blur' },
  488. { required: true, message: '请选择启用日期', trigger: 'change' },
  489. { validator: this.validateStartDate, trigger: 'change' }
  490. ],
  491. stopDate: [
  492. { required: true, message: '请选择停用时间', trigger: 'change' },
  493. { validator: this.validateStopDate, trigger: 'change' }
  494. ],
  495. deviceName: [
  496. { required: true, message: '请输入选择设备', trigger: 'blur' }
  497. ]
  498. },
  499. recordSheet: [], // 记录表
  500. current: {},
  501. dataIndex: null,
  502. showEdit: false,
  503. btnLoading: false,
  504. currentRow: null
  505. };
  506. },
  507. mounted() {
  508. this.getByCodeData();
  509. },
  510. methods: {
  511. open(row, type, title) {
  512. this.visible = true;
  513. this.dialogTitle = title;
  514. this.type = type;
  515. console.log('type', type, row);
  516. if (type == 'edit') {
  517. this.$util.assignObject(this.formData, row);
  518. this.formData.startDate = new Date(row.startDate);
  519. this.formData.stopDate = new Date(row.stopDate);
  520. this.formData.classify = this.formData.classify + '';
  521. this.recordrulesDetailPage(row);
  522. this.recordrulesCyclePage(row);
  523. console.log('this.formData', this.formData, this.formData.version);
  524. }
  525. if (type == 'clone') {
  526. this.$util.assignObject(this.formData, row);
  527. this.formData.name = this.formData.name + '-副本';
  528. this.formData.version += 1;
  529. this.formData.fromId = row.id;
  530. this.formData.id = null;
  531. this.formData.startDate = new Date(row.startDate);
  532. this.formData.stopDate = new Date(row.stopDate);
  533. this.formData.classify = this.formData.classify + '';
  534. this.recordrulesDetailPage(row);
  535. this.recordrulesCyclePage(row);
  536. }
  537. if (type == 'add') {
  538. this.formData.version = 1;
  539. // 停用日期 默认为 2099-12-31
  540. this.formData.stopDate = new Date('2099-12-31 00:00:00');
  541. }
  542. },
  543. async getByCodeData() {
  544. let res = await getByCode('record_sheet');
  545. let list = res.data.map((item) => {
  546. let values = Object.keys(item);
  547. return {
  548. value: values[0],
  549. label: item[values[0]]
  550. };
  551. });
  552. this.recordSheet = list;
  553. },
  554. itemDel(index) {
  555. this.formData.recordRulesDetailList.splice(index, 1);
  556. },
  557. /* 打开操作手册编辑款 */
  558. openOperationGuideDialogDialog(row, index) {
  559. this.$refs.operationGuideDialog.open(row, index);
  560. },
  561. handleClose() {
  562. this.visible = false;
  563. this.$refs['formRef'].resetFields();
  564. // 清空表单数据
  565. this.formData = {
  566. id: null,
  567. classify: null,
  568. deviceId: null,
  569. deviceName: '',
  570. frequencyUnit: null,
  571. frequencyValue: null,
  572. name: '',
  573. recordRulesDetailList: [
  574. {
  575. id: 0,
  576. defaultValue: '',
  577. maxValue: null,
  578. minValue: null,
  579. paramType: null,
  580. paramValue: null,
  581. remark: '',
  582. symbol: null,
  583. toolCodes: null,
  584. tools: [],
  585. unitName: null,
  586. productName: '',
  587. productCode: ''
  588. }
  589. ],
  590. recordRulesCycleList: [],
  591. startDate: null,
  592. stopDate: null,
  593. version: 1,
  594. code: '',
  595. fromId: null
  596. };
  597. },
  598. // 保存
  599. confirm() {
  600. console.log('this.formData', this.formData);
  601. // 验证表单规则
  602. this.$refs.formRef.validate(async (valid) => {
  603. if (!valid) {
  604. return false;
  605. }
  606. if (this.formData.recordRulesDetailList.length == 0) {
  607. return this.$message.warning('至少条件一条规则项');
  608. }
  609. try {
  610. this.btnLoading = true;
  611. this.formData.recordRulesCycleList =
  612. this.$refs.cycleMultipleRef.recordRulesCycleList.map(
  613. (i, index) => {
  614. return { ...i, sortNum: index + 1 };
  615. }
  616. );
  617. const body = { ...this.formData };
  618. body.startDate = this.$util.toDateString(
  619. body.startDate,
  620. 'yyyy-MM-dd HH:mm:ss'
  621. );
  622. body.stopDate = this.$util.toDateString(
  623. body.stopDate,
  624. 'yyyy-MM-dd HH:mm:ss'
  625. );
  626. if (this.type == 'add') {
  627. await recordrulesSave(body);
  628. } else if (this.type == 'clone') {
  629. await recordrulesUpdateVersion(body);
  630. } else {
  631. // 编辑
  632. body.fromId = null;
  633. await recordrulesUpdate(body);
  634. }
  635. this.btnLoading = false;
  636. this.$message.success('操作成功');
  637. this.handleClose();
  638. this.$emit('reload');
  639. } catch (error) {
  640. this.btnLoading = false;
  641. }
  642. });
  643. },
  644. // 保存并发布
  645. saveAndPublish() {
  646. // 验证表单规则
  647. this.$refs.formRef.validate(async (valid) => {
  648. if (!valid) {
  649. return false;
  650. }
  651. if (this.formData.recordRulesDetailList.length == 0) {
  652. return this.$message.warning('至少条件一条规则项');
  653. }
  654. try {
  655. this.btnLoading = true;
  656. this.formData.recordRulesCycleList =
  657. this.$refs.cycleMultipleRef.recordRulesCycleList.map(
  658. (i, index) => {
  659. return { ...i, sortNum: index + 1 };
  660. }
  661. );
  662. const body = { ...this.formData };
  663. body.startDate = this.$util.toDateString(
  664. body.startDate,
  665. 'yyyy-MM-dd HH:mm:ss'
  666. );
  667. body.stopDate = this.$util.toDateString(
  668. body.stopDate,
  669. 'yyyy-MM-dd HH:mm:ss'
  670. );
  671. await recordrulesSaveAndPublish(body);
  672. this.btnLoading = false;
  673. this.$message.success('操作成功');
  674. this.handleClose();
  675. this.$emit('reload');
  676. } catch (error) {
  677. this.btnLoading = false;
  678. }
  679. });
  680. },
  681. // startDate 启用日期要大于当前时间
  682. validateStartDate(rule, value, callback) {
  683. const startDate = this.formData.startDate;
  684. if (!startDate) {
  685. return callback(new Error('启用日期不能为空'));
  686. }
  687. // 启用日期大于等于今天
  688. const today = new Date();
  689. today.setHours(0, 0, 0, 0); // 设置为当天的开始时间
  690. if (new Date(startDate) < today) {
  691. return callback(new Error('启用日期必须大于等于当前日期'));
  692. }
  693. callback();
  694. },
  695. // stopDate 停用时间要大于当前时间并且大于启用日期
  696. validateStopDate(rule, value, callback) {
  697. const startDate = this.formData.startDate;
  698. const stopDate = this.formData.stopDate;
  699. if (
  700. stopDate &&
  701. startDate &&
  702. new Date(stopDate) <= new Date(startDate)
  703. ) {
  704. return callback(new Error('停用时间必须大于启用日期'));
  705. }
  706. callback();
  707. },
  708. // 去选择设备
  709. selectDeviceId() {
  710. this.$refs.deviceSelectDialog.open([]);
  711. },
  712. // 选择设备回调
  713. chooseEquipment(data, index, categoryId) {
  714. console.log('data', data, index, categoryId);
  715. this.formData.deviceId = data[0]?.id || null;
  716. this.formData.deviceName = data[0]?.name || '';
  717. },
  718. // 添加
  719. addRow() {
  720. this.formData.recordRulesDetailList.push({
  721. id: new Date().getTime(),
  722. defaultValue: '',
  723. maxValue: null,
  724. minValue: null,
  725. paramType: null,
  726. paramValue: null,
  727. remark: '',
  728. symbol: null,
  729. tools: [],
  730. unitName: null,
  731. productName: '',
  732. productCode: ''
  733. });
  734. },
  735. deleteRow(row) {
  736. const index = this.formData.recordRulesDetailList.indexOf(row);
  737. if (index !== -1) {
  738. this.formData.recordRulesDetailList.splice(index, 1);
  739. }
  740. },
  741. handleAdd(row) {
  742. this.currentRow = row;
  743. this.$refs.toolModalRef.open(row.toolCodes);
  744. },
  745. chooseModal(data) {
  746. console.log('data', data);
  747. this.currentRow.tools = data.map((i) => {
  748. return {
  749. toolCode: i.code,
  750. toolName: i.name
  751. // rulesDetailId: this.currentRow.id,
  752. // rulesId: this.formData.id
  753. };
  754. });
  755. },
  756. // 规则明细表
  757. async recordrulesDetailPage(row) {
  758. const { list } = await recordrulesDetailPage({
  759. // deptId: row.deptId,
  760. pageNum: 1,
  761. rulesId: row.id,
  762. size: 9999
  763. });
  764. console.log('list 数据', list);
  765. this.formData.recordRulesDetailList = list;
  766. },
  767. // 清空工具
  768. clearTool(row) {
  769. row.tools = [];
  770. },
  771. // 查询 recordrulesCyclePage
  772. async recordrulesCyclePage(row) {
  773. const { list } = await recordrulesCyclePage({
  774. pageNum: 1,
  775. size: 9999,
  776. recordRulesId: row.id,
  777. orderBy: 'descending'
  778. });
  779. console.log('list 周期数据', list);
  780. this.formData.recordRulesCycleList = list;
  781. this.$nextTick(() => {
  782. this.$refs.cycleMultipleRef.setRecordRulesCycleList(list);
  783. });
  784. },
  785. // 去选择产品
  786. selectProduct(row) {
  787. this.currentRow = row;
  788. this.$refs.ProductModalRef.open();
  789. },
  790. // 选择产品
  791. changeProduct(current) {
  792. console.log('current', current);
  793. this.currentRow.productName = current.name;
  794. this.currentRow.productCode = current.code;
  795. },
  796. // 清空产品
  797. clearProduct(row) {
  798. row.productName = '';
  799. row.productCode = '';
  800. }
  801. }
  802. };
  803. </script>
  804. <style scoped lang="scss">
  805. .operationGuide_box {
  806. width: 100%;
  807. height: 48px;
  808. display: flex;
  809. overflow: hidden;
  810. cursor: pointer;
  811. box-sizing: border-box;
  812. padding: 5px 10px;
  813. .left_content {
  814. width: 50%;
  815. padding: 10px;
  816. box-sizing: border-box;
  817. border: 1px solid #c0c4cc;
  818. border-radius: 10px;
  819. margin-right: 10px;
  820. overflow-y: auto;
  821. }
  822. .right_content {
  823. flex: 1;
  824. padding: 10px;
  825. box-sizing: border-box;
  826. border: 1px solid #c0c4cc;
  827. border-radius: 10px;
  828. overflow-y: auto;
  829. }
  830. }
  831. ::v--deep .table_list {
  832. .el-form-item {
  833. .el-form-item__content {
  834. margin-left: 0;
  835. }
  836. }
  837. }
  838. </style>