programRulesDialog.vue 35 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136
  1. <template>
  2. <ele-modal
  3. width="80%"
  4. :visible="visible"
  5. v-if="visible"
  6. :append-to-body="true"
  7. custom-class="ele-dialog-form"
  8. :title="dialogTitle"
  9. @update:visible="updateVisible"
  10. >
  11. <header-title title="基本信息"></header-title>
  12. <el-form
  13. ref="addFormRef"
  14. :model="addForm"
  15. :rules="addFormRules"
  16. label-width="120px"
  17. >
  18. <el-row>
  19. <el-col :span="8">
  20. <el-form-item label="计划配置单号" prop="code">
  21. <el-input
  22. v-model="addForm.code"
  23. size="small"
  24. placeholder="自动带出"
  25. disabled
  26. ></el-input>
  27. </el-form-item>
  28. </el-col>
  29. <el-col :span="8">
  30. <el-form-item label="计划配置名称" prop="name">
  31. <el-input
  32. :disabled="dialogTitle === '派单'"
  33. v-model="addForm.name"
  34. size="small"
  35. placeholder="请输入"
  36. ></el-input>
  37. </el-form-item>
  38. </el-col>
  39. <el-col :span="8">
  40. <el-form-item label="自动派单" prop="autoOrder">
  41. <el-select
  42. :disabled="dialogTitle === '派单'"
  43. v-model="addForm.autoOrder"
  44. size="small"
  45. style="width: 100%"
  46. @change="autoOrderChange"
  47. >
  48. <el-option :value="1" label="是"></el-option>
  49. <el-option :value="0" label="否"></el-option>
  50. </el-select>
  51. </el-form-item>
  52. </el-col>
  53. <el-col :span="8">
  54. <el-form-item label="计划完成时长" prop="duration">
  55. <div style="display: flex">
  56. <el-input
  57. type="number"
  58. :disabled="dialogTitle === '派单'"
  59. v-model="addForm.duration"
  60. size="small"
  61. placeholder="请输入"
  62. @input="formDataDurationTime"
  63. >
  64. <template #suffix>分钟</template>
  65. </el-input>
  66. </div>
  67. </el-form-item>
  68. </el-col>
  69. <el-col :span="8" v-if="addForm.autoOrder">
  70. <el-form-item label="部门" prop="groupId">
  71. <deptSelect
  72. v-model="addForm.groupId"
  73. @changeGroup="searchDeptNodeClick"
  74. :disabled="isBindPlan"
  75. />
  76. </el-form-item>
  77. </el-col>
  78. <el-col :span="8" v-if="addForm.autoOrder">
  79. <el-form-item label="负责人" prop="executeId">
  80. <el-select
  81. v-model="addForm.executeId"
  82. size="small"
  83. style="width: 100%"
  84. :disabled="isBindPlan"
  85. multiple
  86. filterable
  87. >
  88. <el-option
  89. v-for="item in executorList"
  90. :key="item.id"
  91. :value="item.id"
  92. :label="item.name"
  93. ></el-option>
  94. </el-select>
  95. </el-form-item>
  96. </el-col>
  97. <el-col :span="8">
  98. <el-form-item label="审核人" prop="approvalUserId">
  99. <el-select
  100. :disabled="dialogTitle === '派单'"
  101. v-model="addForm.approvalUserId"
  102. size="small"
  103. clearable
  104. style="width: 100%"
  105. filterable
  106. >
  107. <el-option
  108. v-for="item in uerList"
  109. :key="item.id"
  110. :value="item.id"
  111. :label="item.name"
  112. ></el-option>
  113. </el-select>
  114. </el-form-item>
  115. </el-col>
  116. <el-col :span="8">
  117. <el-form-item label="紧急程度" prop="urgent">
  118. <DictSelection
  119. dictName="紧急程度"
  120. clearable
  121. v-model="addForm.urgent"
  122. :disabled="dialogTitle === '派单'"
  123. >
  124. </DictSelection>
  125. </el-form-item>
  126. </el-col>
  127. <!-- <el-col :span="8">
  128. <el-form-item label="状态" prop="status">
  129. <el-switch
  130. v-model="addForm.status"
  131. active-text="开"
  132. inactive-text="关"
  133. :active-value="1"
  134. :inactive-value="0"
  135. />
  136. </el-form-item>
  137. </el-col> -->
  138. <el-col :span="16">
  139. <el-form-item label="备注" prop="remark">
  140. <el-input
  141. type="textarea"
  142. resize="none"
  143. v-model="addForm.remark"
  144. :rows="2"
  145. placeholder="请详细说明"
  146. size="small"
  147. :disabled="dialogTitle === '派单'"
  148. ></el-input>
  149. </el-form-item>
  150. </el-col>
  151. </el-row>
  152. <el-button
  153. v-if="dialogTitle.includes('新增')"
  154. type="primary"
  155. size="small"
  156. style="margin-bottom: 10px"
  157. @click="handleAddTab"
  158. >添加规则</el-button
  159. >
  160. <el-tabs
  161. v-model="tabsValue"
  162. type="card"
  163. :closable="dialogTitle !== '派单'"
  164. @tab-click="handleTab"
  165. @tab-remove="removeTab"
  166. >
  167. <el-tab-pane
  168. v-for="(item, ruleIdListIndex) in ruleIdList"
  169. :key="item.ruleId"
  170. :label="item.name"
  171. :name="item.ruleId"
  172. >
  173. <div class="el-tab_box">
  174. <div class="equipmentList_box">
  175. <header-title title="设备列表">
  176. <div v-if="dialogTitle !== '派单'">
  177. <el-button
  178. size="small"
  179. icon="el-icon-plus"
  180. class="ele-btn-icon"
  181. type="primary"
  182. @click="handleAdd(ruleIdList, ruleIdListIndex)"
  183. >新增</el-button
  184. >
  185. </div>
  186. </header-title>
  187. <el-table :data="item.equipmentList" border>
  188. <el-table-column label="序号" type="index" width="50">
  189. </el-table-column>
  190. <el-table-column label="设备名称" align="center" prop="name">
  191. <template slot-scope="{ row, $index }">
  192. <template>
  193. {{ row.name }}
  194. </template>
  195. </template>
  196. </el-table-column>
  197. <el-table-column label="编号" align="center" prop="codeNumber">
  198. <template slot-scope="{ row, $index }">
  199. <template>
  200. {{ row.codeNumber }}
  201. </template>
  202. </template>
  203. </el-table-column>
  204. <el-table-column label="固资编码" align="center" prop="fixCode">
  205. <template slot-scope="{ row, $index }">
  206. <template>
  207. {{ row.fixCode }}
  208. </template>
  209. </template>
  210. </el-table-column>
  211. <el-table-column
  212. v-if="dialogTitle !== '派单'"
  213. label="操作"
  214. width="100"
  215. >
  216. <template slot-scope="scope">
  217. <el-button
  218. type="text"
  219. @click="deleteEquipment(scope.$index)"
  220. >删除</el-button
  221. >
  222. </template>
  223. </el-table-column>
  224. </el-table>
  225. </div>
  226. <div class="ruleMatters_box">
  227. <header-title title="规则事项">
  228. <div v-if="dialogTitle !== '派单'">
  229. <el-button
  230. size="small"
  231. icon="el-icon-plus"
  232. class="ele-btn-icon"
  233. type="primary"
  234. @click="addPostscript"
  235. >新增</el-button
  236. >
  237. </div>
  238. </header-title>
  239. <el-table :data="item.ruleItems" border>
  240. <el-table-column label="序号" width="50">
  241. <template slot-scope="scope">
  242. <span>{{ scope.$index + 1 }}</span>
  243. </template>
  244. </el-table-column>
  245. <el-table-column label="事项" prop="name" width="100">
  246. <template slot-scope="scope">
  247. <div v-if="scope.row.isNew">
  248. <el-input
  249. v-model="scope.row.name"
  250. placeholder="请输入内容"
  251. ></el-input>
  252. </div>
  253. <div v-else>
  254. <span>{{ scope.row.name }}</span>
  255. </div>
  256. </template>
  257. </el-table-column>
  258. <el-table-column label="内容" prop="content" width="200">
  259. <template slot-scope="scope">
  260. <div v-if="scope.row.isNew">
  261. <el-input
  262. v-model="scope.row.content"
  263. placeholder="请输入内容"
  264. ></el-input>
  265. </div>
  266. <div v-else>
  267. <span>{{ scope.row.content }}</span>
  268. </div>
  269. </template>
  270. </el-table-column>
  271. <el-table-column label="操作指导" prop="operationGuide">
  272. <template slot-scope="scope">
  273. <div
  274. class="operationGuide_box"
  275. @click="
  276. openOperationGuideDialogDialog(
  277. scope.row.operationGuide,
  278. scope.$index
  279. )
  280. "
  281. >
  282. <div class="left_content">
  283. <template v-if="scope.row.operationGuide">
  284. <div
  285. v-for="(item, index) in scope.row.operationGuide
  286. .toolList"
  287. :key="item.id"
  288. >{{ index + 1 }}.{{ item.name }}</div
  289. >
  290. </template>
  291. </div>
  292. <div class="right_content">
  293. <template v-if="scope.row.operationGuide">
  294. <div
  295. v-for="(item, index) in scope.row.operationGuide
  296. .procedureList"
  297. :key="item.id"
  298. >{{ index + 1 }}.{{ item.content }}</div
  299. >
  300. </template>
  301. </div>
  302. </div>
  303. </template>
  304. </el-table-column>
  305. <el-table-column label="标准" prop="norm" width="100">
  306. <template slot-scope="scope">
  307. <div v-if="scope.row.isNew">
  308. <el-input
  309. v-model="scope.row.norm"
  310. placeholder="请输入内容"
  311. ></el-input>
  312. </div>
  313. <div v-else>
  314. <span>{{ scope.row.norm }}</span>
  315. </div>
  316. </template>
  317. </el-table-column>
  318. <el-table-column
  319. v-if="dialogTitle !== '派单'"
  320. label="操作"
  321. width="100"
  322. >
  323. <template slot-scope="scope">
  324. <el-button type="text" @click="deleteItem(scope.$index)"
  325. >删除</el-button
  326. >
  327. </template>
  328. </el-table-column>
  329. </el-table>
  330. </div>
  331. </div>
  332. </el-tab-pane>
  333. </el-tabs>
  334. </el-form>
  335. <template v-slot:footer>
  336. <el-button @click="visible = false">取消</el-button>
  337. <el-button type="primary" @click="save">
  338. {{ dialogTitle === '派单' ? '派单' : '保存' }}</el-button
  339. >
  340. </template>
  341. <!-- 新增设备 -->
  342. <MaterialAdd ref="productRefs" @chooseEquipment="chooseEquipment">
  343. </MaterialAdd>
  344. <!-- -->
  345. <operation-guideDialog ref="operationGuideDialog" @save="saveEdit" />
  346. <!-- 添加规则 -->
  347. <ele-modal
  348. width="800px"
  349. :visible="addDialog"
  350. :append-to-body="true"
  351. title="规则配置"
  352. :close-on-click-modal="true"
  353. @update:visible="closeAdd"
  354. >
  355. <el-select
  356. v-model="ruleObj.ruleId"
  357. size="small"
  358. style="width: 100%"
  359. @change="handleRuleNameChange"
  360. :disabled="isBindPlan"
  361. filterable
  362. >
  363. <el-option
  364. v-for="item in ruleNameList"
  365. :key="item.id"
  366. :value="item.id"
  367. :label="item.name"
  368. @click.native="ruleChange(item)"
  369. ></el-option>
  370. </el-select>
  371. <template v-slot:footer>
  372. <el-button @click="addDialog = false">取消</el-button>
  373. <el-button type="primary" @click="addRule"> 添加 </el-button>
  374. </template>
  375. </ele-modal>
  376. </ele-modal>
  377. </template>
  378. <script>
  379. import { getDetail, getCode } from '@/api/ruleManagement/matter';
  380. import {
  381. getRule,
  382. getCategory,
  383. getAssetList,
  384. getInfoById
  385. } from '@/api/ruleManagement/plan';
  386. import { saveOrUpdate } from '@/api/maintenance/patrol_maintenance';
  387. import { getUserPage } from '@/api/system/organization';
  388. import { getTreeByType } from '@/api/classifyManage';
  389. import MaterialAdd from './MaterialAdd.vue';
  390. import OperationGuideDialog from './operationGuideDialog.vue';
  391. import deptSelect from '@/components/CommomSelect/dept-select.vue';
  392. import { pageList } from '@/api/technology/version/version.js';
  393. import { getById } from '@/api/maintenance/patrol_maintenance';
  394. import { getFile } from '@/api/system/file';
  395. import { deepClone } from 'ele-admin/lib/utils/core';
  396. export default {
  397. components: {
  398. MaterialAdd,
  399. deptSelect,
  400. OperationGuideDialog
  401. },
  402. props: {
  403. dialogTitle: {
  404. type: String,
  405. default: () => {
  406. return '新增巡检点计划配置';
  407. }
  408. },
  409. visible: {
  410. type: Boolean,
  411. default: false
  412. }
  413. },
  414. data() {
  415. const defaultForm = {
  416. id: null,
  417. code: '',
  418. name: '',
  419. modelType: '',
  420. brandNum: '',
  421. specification: '',
  422. measuringUnit: '',
  423. bomList: []
  424. };
  425. return {
  426. ruleIndex: 0, // 规则index
  427. ruleId: '',
  428. formLabel: '',
  429. isBindPlan: false,
  430. ruleObj: {
  431. ruleId: '',
  432. name: '',
  433. code: '',
  434. equipmentList: []
  435. },
  436. ruleIdList: [],
  437. addForm: {
  438. id: '',
  439. code: '', // 计划配置单号
  440. name: '', // 计划配置名称
  441. autoOrder: 1, // 自动派单
  442. ruleId: '', // 规则id
  443. ruleName: '', // 规则名称
  444. duration: null, // 计划完成时长
  445. categoryId: '', // 设备类别id
  446. approvalUserId: '', // 审核人id
  447. groupId: '', // 巡点检部门code
  448. executeId: [], // 巡点检人员id
  449. executorPhone: '',
  450. status: 1, // 状态
  451. remark: '', // 备注
  452. urgent: '1'
  453. },
  454. ruleNameList: [], // 规则列表
  455. uerList: [], // 审核人列表
  456. executorList: [], // 业务人员列表
  457. defaultForm,
  458. // 表单数据
  459. form: {
  460. ...defaultForm
  461. },
  462. versionList: [],
  463. // 表单验证规则
  464. addFormRules: {
  465. name: [
  466. { required: true, message: '请输入计划配置名称', trigger: 'blur' }
  467. ],
  468. autoOrder: [
  469. { required: true, message: '请选择是否自动派单', trigger: 'change' }
  470. ],
  471. ruleId: [
  472. { required: true, message: '请选择规则名称', trigger: 'change' }
  473. ],
  474. duration: [
  475. { required: true, message: '请输入计划完成时长', trigger: 'blur' }
  476. ],
  477. categoryLevelId: [
  478. { required: true, message: '请选择设备分类', trigger: 'change' }
  479. ],
  480. categoryId: [
  481. { required: true, message: '请选择设备类别', trigger: 'change' }
  482. ],
  483. groupId: [
  484. { required: true, message: '请选择巡点检部门', trigger: 'change' }
  485. ],
  486. executeId: [
  487. { required: true, message: '请选择巡点检人员', trigger: 'change' }
  488. ],
  489. urgent: [
  490. { required: true, message: '请选择紧急程度', trigger: 'change' }
  491. ]
  492. },
  493. columns: [
  494. {
  495. type: 'index',
  496. width: 55,
  497. align: 'center'
  498. },
  499. {
  500. label: '子项编号',
  501. prop: 'subCode',
  502. action: 'subCode'
  503. },
  504. {
  505. label: '物料名称',
  506. prop: 'categoryName',
  507. action: 'categoryName'
  508. },
  509. {
  510. label: '是否回收料',
  511. prop: 'isReworkBom',
  512. action: 'isReworkBom',
  513. slot: 'isReworkBom',
  514. width: 95
  515. },
  516. {
  517. label: '物料编码',
  518. prop: 'categoryCode'
  519. },
  520. {
  521. label: '牌号',
  522. prop: 'brandNum'
  523. },
  524. {
  525. label: '型号',
  526. prop: 'modelType'
  527. },
  528. {
  529. label: '数量',
  530. prop: 'count'
  531. },
  532. {
  533. label: '计量单位',
  534. prop: 'unit'
  535. },
  536. {
  537. label: '附件',
  538. slot: 'bomArtFiles',
  539. action: 'bomArtFiles',
  540. minWidth: 100
  541. },
  542. {
  543. label: '单位',
  544. prop: 'weightUnit'
  545. },
  546. {
  547. label: '备注',
  548. prop: 'remark'
  549. }
  550. ],
  551. statusList: [
  552. { label: '草稿', value: -1 },
  553. { label: '失效', value: 0 },
  554. { label: '生效', value: 1 }
  555. ],
  556. // 提交状态
  557. loading: false,
  558. categoryId: null,
  559. current: null,
  560. materialShow: false,
  561. tabsList: [],
  562. tableData: [],
  563. taskId: null,
  564. addDialog: false,
  565. tabsValue: null
  566. };
  567. },
  568. computed: {
  569. // 是否开启响应式布局
  570. styleResponsive() {
  571. return this.$store.state.theme.styleResponsive;
  572. }
  573. },
  574. watch: {
  575. visible(val) {
  576. if (val) {
  577. // 获取审核人列表数据
  578. this.getUserList();
  579. // 获取规则名称
  580. this._getRuleNameList();
  581. }
  582. }
  583. },
  584. methods: {
  585. // 初始化
  586. async init(row, tips) {
  587. console.log(row);
  588. console.log(tips);
  589. if (row) {
  590. this.getInfo(row.id, tips);
  591. } else {
  592. // 获取计划配置单号
  593. this.getOrderCode(tips);
  594. this.addForm = {
  595. code: '', // 计划配置单号
  596. name: '', // 计划配置名称
  597. autoOrder: 1, // 自动派单
  598. ruleId: '', // 规则id
  599. ruleName: '', // 规则名称
  600. duration: null, // 计划完成时长
  601. categoryId: '', // 设备类别id
  602. approvalUserId: '', // 审核人id
  603. groupId: '', // 巡点检部门code
  604. executeId: [], // 巡点检人员id
  605. executorPhone: '',
  606. status: 1, // 状态
  607. remark: '', // 备注
  608. urgent: '1'
  609. };
  610. this.ruleIdList = [];
  611. this.isBindPlan = false;
  612. this.planRuleEquiList = [];
  613. // this.matterRulesList = [];
  614. }
  615. this.formLabel = this.dialogTitle.includes('巡点检')
  616. ? '巡点检'
  617. : this.dialogTitle.includes('保养')
  618. ? '保养'
  619. : this.dialogTitle.includes('量具送检')
  620. ? '量具送检'
  621. : '盘点';
  622. const typeOptions = {
  623. 巡点检: 1,
  624. 保养: 2,
  625. 维修: 3,
  626. 计划性维修: 4,
  627. 量具送检: 5
  628. };
  629. this.addForm.type = typeOptions[this.formLabel];
  630. // const planRuleTypeObj = {
  631. // 巡点检: 'PATROL',
  632. // 保养: 'MAINTAIN',
  633. // 量具送检: '',
  634. // 盘点: 'INVENTORY'
  635. // };
  636. // this.addForm.planType = planRuleTypeObj[this.formLabel];
  637. },
  638. autoOrderChange(val) {
  639. if (val == 0) {
  640. this.addForm.executeId = '';
  641. this.addForm.groupId = '';
  642. }
  643. },
  644. ruleChange(item) {
  645. this.ruleObj.name = item.name;
  646. this.ruleObj.code = item.code;
  647. },
  648. save() {
  649. console.log(this.addForm);
  650. console.log(this.ruleIdList);
  651. if (this.ruleIdList && this.ruleIdList.length > 0) {
  652. this.$refs.addFormRef.validate(async (valid) => {
  653. console.log(valid);
  654. if (valid) {
  655. const planDeviceList = this.ruleIdList.map((ruleItem) => {
  656. return ruleItem.equipmentList.map((item) => {
  657. return {
  658. // equiCode: item.code,
  659. // equiName: item.name,
  660. deviceId: item.id,
  661. codeNumber: item.codeNumber,
  662. // equiModel: item.modelType,
  663. equiLocation: item.position[0].pathName,
  664. equiLocationCode: item.position[0].pathIds,
  665. workItems: ruleItem.ruleItems ? ruleItem.ruleItems : []
  666. // categoryId: item.category.categoryLevelId,
  667. // categoryName: item.category.categoryLevelName
  668. // sparePart: ruleItem.sparePart ? obj.sparePart : []
  669. };
  670. });
  671. });
  672. let boolen = planDeviceList.every((item) => item.length > 0);
  673. console.log(planDeviceList);
  674. if (!boolen) {
  675. this.$message.error('请添加设备!');
  676. return false;
  677. }
  678. let sendMsg = this.ruleIdList.map((item, index) => {
  679. return {
  680. ...this.addForm,
  681. ruleId: item.ruleId,
  682. categoryId: item.categoryId,
  683. planDeviceList: planDeviceList[index],
  684. executorId: this.addForm.executeId
  685. ? this.addForm.executeId.join(',')
  686. : ''
  687. };
  688. });
  689. let type = '';
  690. if (this.dialogTitle === '派单') {
  691. type = '派单';
  692. } else {
  693. type = this.dialogTitle.includes('新增') ? '新增' : '编辑';
  694. }
  695. try {
  696. let res = await saveOrUpdate(sendMsg);
  697. if (res) {
  698. this.$message.success(type + '成功!');
  699. this.$emit('done');
  700. }
  701. } catch (error) {
  702. this.$message.error(type + '失败!');
  703. }
  704. }
  705. });
  706. } else {
  707. this.$message.error('请添加规则!');
  708. }
  709. },
  710. // 保存操作指导数据
  711. saveEdit(data, index) {
  712. console.log(this.matterRulesList);
  713. console.log(data);
  714. console.log(index);
  715. this.$set(
  716. this.ruleIdList[this.ruleIndex].ruleItems[index],
  717. 'operationGuide',
  718. data
  719. );
  720. },
  721. /* 打开操作手册编辑款 */
  722. openOperationGuideDialogDialog(row, index) {
  723. if (this.dialogTitle !== '派单') {
  724. this.$refs.operationGuideDialog.open(row, index);
  725. }
  726. },
  727. deleteEquipment(index) {
  728. this.ruleIdList[this.ruleIndex].equipmentList.splice(index, 1);
  729. },
  730. deleteItem(index) {
  731. if (this.ruleIdList[this.ruleIndex].ruleItems.length > 1) {
  732. this.ruleIdList[this.ruleIndex].ruleItems.splice(index, 1);
  733. } else {
  734. this.$message.error('至少要有一个规则事项!');
  735. }
  736. },
  737. addPostscript() {
  738. console.log(
  739. 'this.matterRulesList---------------',
  740. this.matterRulesList
  741. );
  742. this.ruleIdList[this.ruleIndex].ruleItems.push({
  743. sort: null,
  744. name: '',
  745. content: '',
  746. norm: '',
  747. isNew: true,
  748. operationGuide: {
  749. procedureList: [],
  750. toolList: []
  751. }
  752. });
  753. },
  754. async getInfo(id, tips) {
  755. console.log(id);
  756. try {
  757. const res = await getById(id);
  758. console.log('res----------', res);
  759. this.addForm = res.data;
  760. this.addForm.id = res.data.planId;
  761. if (this.dialogTitle === '派单') {
  762. this.addForm.autoOrder = 1;
  763. }
  764. this.isBindPlan = res.isBindPlan;
  765. // this.categoryEquipment(res.categoryLevelId);
  766. this.ruleIdList = [
  767. {
  768. id: res.data.id,
  769. ruleId: res.data.ruleId,
  770. name: res.data.name,
  771. code: res.data.code,
  772. categoryId: res.data.categoryId,
  773. equipmentList: res.data.planDeviceList.map((item) => {
  774. return {
  775. name: item.substance.name,
  776. position: item.substance.position,
  777. id: item.substance.id,
  778. fixCode: item.substance.fixCode,
  779. codeNumber: item.substance.codeNumber
  780. // category: {
  781. // categoryLevelId: item.categoryId,
  782. // categoryLevelName: item.categoryName
  783. // }
  784. };
  785. }),
  786. ruleItems: res.data.planDeviceList[0].workItems
  787. }
  788. ];
  789. console.log(this.ruleIdList);
  790. this.tabsValue = this.ruleIdList[0].ruleId;
  791. // const params = { groupId: res.data.groupId };
  792. // this.getUserList(params);
  793. // this._getMatterRulesDetails(res.ruleId);
  794. this.$set(this.addForm, 'code', res.data.code);
  795. this.$set(this.addForm, 'urgent', JSON.stringify(res.data.urgent));
  796. this.$set(this.addForm, 'executeId', res.data.executeId.split(','));
  797. this.$set(this.addForm, 'imageUrl', {});
  798. console.log(this.rootData);
  799. // const rep = await getTreeByType(0);
  800. // console.log('sasas', res);
  801. // const ids = this.findTopLevelAncestorId(
  802. // rep.data,
  803. // res.categoryLevelId
  804. // );
  805. // this.rootId = ids;
  806. // // await this._getEquipmentList(res.categoryLevelId, this.isBindPlan);
  807. // let keys = [];
  808. // res.deviceInfo.map((item) => {
  809. // keys.push(item.substanceId);
  810. // });
  811. // this.$nextTick(() => {
  812. // this.$refs.equiListTree.setCheckedKeys(keys);
  813. // });
  814. // this.clickedTreeNode = true;
  815. } catch (error) {
  816. console.log(error);
  817. }
  818. },
  819. // 获取设备分类数据
  820. async categoryEquipment(id) {
  821. const params = { categoryLevelId: id, pageNum: 1, size: -1 };
  822. console.log('params==', params);
  823. const data = await getCategory(params);
  824. console.log(data);
  825. this.equipmentList = data.list;
  826. },
  827. // 选择设备
  828. chooseEquipment(data, index, categoryId) {
  829. this.$set(
  830. this.ruleIdList[index],
  831. 'equipmentList',
  832. this.ruleIdList[index].equipmentList.concat(data)
  833. );
  834. this.$set(this.ruleIdList[index], 'categoryId', categoryId);
  835. console.log(this.ruleIdList);
  836. },
  837. // 获取计划配置单号
  838. async getOrderCode(tips) {
  839. if (tips.includes('巡点检')) {
  840. const data = await getCode('patrolconfig_code');
  841. this.$set(this.addForm, 'code', data);
  842. }
  843. if (tips.includes('保养')) {
  844. const code = await getCode('maintainconfig_code');
  845. this.$set(this.addForm, 'code', code);
  846. }
  847. if (tips.includes('量具送检')) {
  848. const code = await getCode('quantity_code');
  849. this.$set(this.addForm, 'code', code);
  850. }
  851. },
  852. //选择部门(搜索)
  853. searchDeptNodeClick(info, data) {
  854. if (info) {
  855. // 根据部门获取人员
  856. this.addForm.groupName = data.name;
  857. const params = { groupId: info };
  858. this.getUserList(params);
  859. } else {
  860. this.addForm.groupId = null;
  861. }
  862. },
  863. // 过滤计划完成时长
  864. formDataDurationTime(value) {
  865. if (value > 0) {
  866. this.addForm.duration = value.replace(/^[0]+/, '');
  867. } else {
  868. this.addForm.duration = 0;
  869. }
  870. },
  871. // 获取审核人列表、巡点检人员
  872. async getUserList(params) {
  873. try {
  874. let data = { pageNum: 1, size: -1 };
  875. // 如果传了参数就是获取巡点检人员数据
  876. if (params) {
  877. data = Object.assign(data, params);
  878. }
  879. const res = await getUserPage(data);
  880. console.log('res------------', res);
  881. if (params) {
  882. this.executorList = res.list;
  883. } else {
  884. this.uerList = res.list;
  885. }
  886. } catch (error) {}
  887. },
  888. // 获取规则名列表
  889. async _getRuleNameList() {
  890. if (
  891. this.dialogTitle === '新增保养计划配置' ||
  892. this.dialogTitle === '编辑保养计划配置'
  893. ) {
  894. const res = await getRule({
  895. status: 1,
  896. type: 2,
  897. pageNum: 1,
  898. size: -1
  899. });
  900. if (res.list) {
  901. this.ruleNameList = res.list || [];
  902. }
  903. }
  904. if (
  905. this.dialogTitle === '新增巡点检计划配置' ||
  906. this.dialogTitle === '编辑巡点检计划配置'
  907. ) {
  908. const res = await getRule({
  909. status: 1,
  910. type: 1,
  911. pageNum: 1,
  912. size: -1
  913. });
  914. if (res.list) {
  915. this.ruleNameList = res.list || [];
  916. }
  917. }
  918. if (
  919. this.dialogTitle === '新增量具送检计划配置' ||
  920. this.dialogTitle === '编辑量具送检计划配置'
  921. ) {
  922. const res = await getRule({
  923. status: 1,
  924. type: 5,
  925. pageNum: 1,
  926. size: -1
  927. });
  928. if (res.list) {
  929. this.ruleNameList = res.list || [];
  930. }
  931. }
  932. },
  933. downloadFile(file) {
  934. getFile({ objectName: file.storePath }, file.name);
  935. },
  936. openEdit(index) {
  937. this.current = this.form.bomList[index];
  938. console.log(this.current);
  939. this.materialShow = true;
  940. },
  941. /* 表格数据源 */
  942. datasource({ page, limit, where }) {
  943. return [];
  944. },
  945. async getVersionList() {
  946. const res = await pageList({
  947. pageNum: 1,
  948. size: 100
  949. });
  950. this.versionList = res.list;
  951. },
  952. handleAdd(ruleIdList, ruleIdListIndex) {
  953. this.$refs.productRefs.open(ruleIdList, ruleIdListIndex);
  954. },
  955. /* 更新visible */
  956. updateVisible(value) {
  957. this.$emit('update:visible', value);
  958. },
  959. handleAddTab() {
  960. this.tableData = this.tabsList;
  961. this.addDialog = true;
  962. },
  963. handleTab(e) {
  964. this.ruleIndex = e.index;
  965. // this.ruleIdList[e.index].ruleItems = this._getMatterRulesDetails(this.ruleId)
  966. },
  967. removeTab(targetName) {
  968. this.$confirm('是否删除当前工序?', '提示', {
  969. confirmButtonText: '确定',
  970. cancelButtonText: '取消',
  971. type: 'warning'
  972. })
  973. .then(() => {
  974. this.ruleIdList.forEach((e, index) => {
  975. if (e.ruleId == targetName) {
  976. this.ruleIdList.splice(index, 1);
  977. this.$nextTick(() => {
  978. if (this.ruleIdList.length == 1) {
  979. this.tabsValue = this.ruleIdList[0].ruleId;
  980. }
  981. });
  982. }
  983. });
  984. })
  985. .catch(() => {});
  986. },
  987. /*关闭选择参数*/
  988. closeAdd() {
  989. this.addDialog = false;
  990. },
  991. // 规则名称下拉触发
  992. handleRuleNameChange(val) {
  993. this.ruleId = val;
  994. console.log('val----', val);
  995. // this._getMatterRulesDetails(val);
  996. },
  997. // 封装 - 获取规则下面的详情数据及事项
  998. async _getMatterRulesDetails(val) {
  999. const res = await getDetail(val);
  1000. return res.ruleItems;
  1001. // console.log('res------', res);
  1002. // this.matterRulesList = res.ruleItems;
  1003. },
  1004. async addRule() {
  1005. console.log(this.ruleIdList);
  1006. console.log(this.ruleId);
  1007. let boolen = this.ruleIdList.every((item) => {
  1008. return this.ruleId != item.ruleId;
  1009. });
  1010. if (boolen) {
  1011. console.log(this.ruleNameList);
  1012. this.ruleObj.ruleItems = await this._getMatterRulesDetails(
  1013. this.ruleId
  1014. );
  1015. this.ruleIdList.push(deepClone(this.ruleObj));
  1016. console.log('this.ruleIdList--------', this.ruleIdList);
  1017. this.addDialog = false;
  1018. this.$nextTick(() => {
  1019. if (this.ruleIdList.length == 1) {
  1020. this.tabsValue = this.ruleIdList[0].ruleId;
  1021. }
  1022. });
  1023. } else {
  1024. this.$message.error('请误重复添加规则');
  1025. }
  1026. }
  1027. }
  1028. };
  1029. </script>
  1030. <style lang="scss" scoped>
  1031. ::v-deep .el-row {
  1032. display: flex;
  1033. flex-wrap: wrap;
  1034. }
  1035. ::v-deep .el-tab_box {
  1036. display: flex;
  1037. margin-top: 10px;
  1038. height: 300px;
  1039. width: 100%;
  1040. .equipmentList_box {
  1041. flex: 1;
  1042. height: 100%;
  1043. margin-right: 10px;
  1044. display: flex;
  1045. flex-direction: column;
  1046. .divider {
  1047. flex: 0 0 50px;
  1048. .title {
  1049. height: 35px;
  1050. }
  1051. }
  1052. .el-table {
  1053. overflow: auto;
  1054. }
  1055. }
  1056. .ruleMatters_box {
  1057. flex: 3;
  1058. height: 100%;
  1059. display: flex;
  1060. flex-direction: column;
  1061. overflow: hidden;
  1062. .divider {
  1063. flex: 0 0 50px;
  1064. .title {
  1065. height: 35px;
  1066. }
  1067. }
  1068. .el-table {
  1069. overflow: auto;
  1070. .operationGuide_box {
  1071. width: 100%;
  1072. height: 50px;
  1073. display: flex;
  1074. overflow: hidden;
  1075. cursor: pointer;
  1076. .left_content {
  1077. flex: 0 0 200px;
  1078. padding: 10px;
  1079. box-sizing: border-box;
  1080. border: 1px solid #c0c4cc;
  1081. border-radius: 10px;
  1082. margin-right: 10px;
  1083. overflow-y: auto;
  1084. }
  1085. .right_content {
  1086. flex: 1;
  1087. padding: 10px;
  1088. box-sizing: border-box;
  1089. border: 1px solid #c0c4cc;
  1090. border-radius: 10px;
  1091. overflow-y: auto;
  1092. }
  1093. }
  1094. }
  1095. .el-table::before {
  1096. display: none;
  1097. }
  1098. }
  1099. }
  1100. </style>