permitAdd.vue 26 KB

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