programRulesDialog.vue 44 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438
  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. :maxable="true"
  11. >
  12. <header-title title="基本信息"></header-title>
  13. <el-form
  14. ref="addFormRef"
  15. :model="addForm"
  16. :rules="addFormRules"
  17. label-width="120px"
  18. >
  19. <el-row>
  20. <el-col :span="8">
  21. <el-form-item label="计划配置单号" prop="code">
  22. <el-input
  23. v-model="addForm.code"
  24. size="small"
  25. placeholder="自动带出"
  26. disabled
  27. ></el-input>
  28. </el-form-item>
  29. </el-col>
  30. <el-col :span="8">
  31. <el-form-item label="计划配置名称" prop="name">
  32. <el-input
  33. v-model="addForm.name"
  34. size="small"
  35. placeholder="请输入"
  36. :disabled="isBindPlan"
  37. ></el-input>
  38. </el-form-item>
  39. </el-col>
  40. <el-col :span="8">
  41. <el-form-item label="自动派单" prop="autoOrder">
  42. <el-select
  43. v-model="addForm.autoOrder"
  44. size="small"
  45. style="width: 100%"
  46. :disabled="isBindPlan"
  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. v-model="addForm.duration"
  59. size="small"
  60. placeholder="请输入"
  61. :disabled="isBindPlan"
  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="!dialogTitle.includes('量具送检')">
  70. <el-form-item label="类型" prop="type">
  71. <el-select
  72. v-model="addForm.type"
  73. :disabled="isBindPlan"
  74. size="small"
  75. @change="typeChange"
  76. style="width: 100%"
  77. >
  78. <el-option :value="1" label="班组"></el-option>
  79. <el-option :value="0" label="个人"></el-option>
  80. </el-select>
  81. </el-form-item>
  82. </el-col>
  83. <el-col
  84. :span="8"
  85. v-if="
  86. dispatchType &&
  87. addForm.type == 1 &&
  88. !dialogTitle.includes('量具送检')
  89. "
  90. >
  91. <el-form-item label="班组" prop="teamId">
  92. <el-select
  93. v-model="addForm.teamId"
  94. :disabled="isBindPlan"
  95. size="small"
  96. @change="teamChange"
  97. style="width: 100%"
  98. >
  99. <el-option
  100. :value="i.id"
  101. :label="i.name"
  102. v-for="i in teamAllList"
  103. :key="i.id"
  104. ></el-option>
  105. </el-select>
  106. </el-form-item>
  107. </el-col>
  108. <el-col
  109. :span="8"
  110. v-if="
  111. dispatchType &&
  112. addForm.type == 0 &&
  113. !dialogTitle.includes('量具送检')
  114. "
  115. >
  116. <el-form-item label="部门" prop="groupId">
  117. <deptSelect
  118. v-model="addForm.groupId"
  119. @changeGroup="searchDeptNodeClick"
  120. :disabled="isBindPlan"
  121. />
  122. </el-form-item>
  123. </el-col>
  124. <el-col
  125. :span="8"
  126. v-if="
  127. dispatchType &&
  128. addForm.type == 0 &&
  129. !dialogTitle.includes('量具送检')
  130. "
  131. >
  132. <!-- <el-form-item label="负责人" prop="executeIdList">
  133. <el-select v-model="addForm.executeIdList" size="small" style="width: 100%" :disabled="isBindPlan" multiple
  134. filterable>
  135. <el-option v-for="item in executorList" :key="item.id" :value="item.id" :label="item.name"></el-option>
  136. </el-select>
  137. </el-form-item> -->
  138. <el-form-item label="负责人" prop="executeIdList">
  139. <el-select
  140. v-model="addForm.executeIdList"
  141. :disabled="isBindPlan"
  142. size="small"
  143. style="width: 100%"
  144. multiple
  145. filterable
  146. @change="executeIdListChange"
  147. >
  148. <el-option
  149. v-for="item in executorList"
  150. :key="item.id"
  151. :value="item.id"
  152. :label="item.name"
  153. ></el-option>
  154. </el-select>
  155. </el-form-item>
  156. </el-col>
  157. <el-col :span="8" v-if="!dialogTitle.includes('量具送检')">
  158. <el-form-item label="审核人" prop="approvalUserId">
  159. <el-select
  160. v-model="addForm.approvalUserId"
  161. size="small"
  162. clearable
  163. style="width: 100%"
  164. :disabled="isBindPlan"
  165. filterable
  166. >
  167. <el-option
  168. v-for="item in uerList"
  169. :key="item.id"
  170. :value="item.id"
  171. :label="item.name"
  172. ></el-option>
  173. </el-select>
  174. </el-form-item>
  175. </el-col>
  176. <el-col :span="8">
  177. <el-form-item label="紧急程度" prop="urgent">
  178. <DictSelection
  179. dictName="紧急程度"
  180. clearable
  181. v-model="addForm.urgent"
  182. :disabled="isBindPlan"
  183. >
  184. </DictSelection>
  185. </el-form-item>
  186. </el-col>
  187. <el-col :span="8">
  188. <el-form-item label="状态" prop="status">
  189. <el-switch
  190. v-model="addForm.status"
  191. active-text="开"
  192. inactive-text="关"
  193. :active-value="1"
  194. :inactive-value="0"
  195. />
  196. </el-form-item>
  197. </el-col>
  198. <el-col :span="16">
  199. <el-form-item label="备注" prop="remark">
  200. <el-input
  201. type="textarea"
  202. resize="none"
  203. v-model="addForm.remark"
  204. :rows="2"
  205. placeholder="请详细说明"
  206. size="small"
  207. :disabled="isBindPlan"
  208. ></el-input>
  209. </el-form-item>
  210. </el-col>
  211. </el-row>
  212. <el-button
  213. type="primary"
  214. size="small"
  215. style="margin-bottom: 10px"
  216. @click="handleAddTab"
  217. >添加规则</el-button
  218. >
  219. <el-tabs
  220. v-model="tabsValue"
  221. type="card"
  222. closable
  223. @tab-click="handleTab"
  224. @tab-remove="removeTab"
  225. >
  226. <el-tab-pane
  227. v-for="(item, ruleIdListIndex) in ruleIdList"
  228. :key="item.ruleId"
  229. :label="item.name"
  230. :name="item.ruleId"
  231. >
  232. <div class="el-tab_box">
  233. <div class="equipmentList_box">
  234. <header-title title="设备列表">
  235. <div>
  236. <el-button
  237. size="small"
  238. icon="el-icon-plus"
  239. class="ele-btn-icon"
  240. type="primary"
  241. :disables="hasCategoryId"
  242. @click="handleAdd(ruleIdList, ruleIdListIndex)"
  243. >新增</el-button
  244. >
  245. </div>
  246. </header-title>
  247. <el-table :data="item.equipmentList" border>
  248. <el-table-column label="序号" type="index" width="50">
  249. </el-table-column>
  250. <el-table-column label="设备名称" align="center" prop="name">
  251. <template slot-scope="{ row }">
  252. <template>
  253. {{ row.name }}
  254. </template>
  255. </template>
  256. </el-table-column>
  257. <el-table-column label="编号" align="center" prop="codeNumber">
  258. <template slot-scope="{ row }">
  259. <template>
  260. {{ row.codeNumber }}
  261. </template>
  262. </template>
  263. </el-table-column>
  264. <el-table-column label="固资编码" align="center" prop="fixCode">
  265. <template slot-scope="{ row }">
  266. <template>
  267. {{ row.fixCode }}
  268. </template>
  269. </template>
  270. </el-table-column>
  271. <el-table-column label="操作" width="100">
  272. <template slot-scope="scope">
  273. <el-button
  274. type="text"
  275. @click="deleteEquipment(scope.$index)"
  276. >删除</el-button
  277. >
  278. </template>
  279. </el-table-column>
  280. </el-table>
  281. </div>
  282. <div class="ruleMatters_box">
  283. <header-title title="规则事项">
  284. <div>
  285. <el-button
  286. size="small"
  287. icon="el-icon-plus"
  288. class="ele-btn-icon"
  289. type="primary"
  290. @click="addPostscript"
  291. >新增</el-button
  292. >
  293. </div>
  294. </header-title>
  295. <el-table :data="item.ruleItems" border>
  296. <el-table-column label="序号" width="50">
  297. <template slot-scope="scope">
  298. <span>{{ scope.$index + 1 }}</span>
  299. </template>
  300. </el-table-column>
  301. <el-table-column
  302. label="零部件编码"
  303. prop="categoryCode"
  304. width="100"
  305. >
  306. <template slot-scope="scope">
  307. <div v-if="scope.row.isNew">
  308. <el-input
  309. v-model="scope.row.categoryCode"
  310. placeholder="请输入零部件编码"
  311. ></el-input>
  312. </div>
  313. <div v-else>
  314. <span>{{ scope.row.categoryCode }}</span>
  315. </div>
  316. </template>
  317. </el-table-column>
  318. <el-table-column
  319. label="零部件名称"
  320. prop="categoryName"
  321. width="100"
  322. >
  323. <template slot-scope="scope">
  324. <div v-if="scope.row.isNew">
  325. <el-input
  326. v-model="scope.row.categoryName"
  327. placeholder="请输入零部件名称"
  328. ></el-input>
  329. </div>
  330. <div v-else>
  331. <span>{{ scope.row.categoryName }}</span>
  332. </div>
  333. </template>
  334. </el-table-column>
  335. <el-table-column label="事项" prop="name" width="100">
  336. <template slot-scope="scope">
  337. <div v-if="scope.row.isNew">
  338. <el-input
  339. v-model="scope.row.name"
  340. placeholder="请输入内容"
  341. ></el-input>
  342. </div>
  343. <div v-else>
  344. <span>{{ scope.row.name }}</span>
  345. </div>
  346. </template>
  347. </el-table-column>
  348. <el-table-column label="内容" prop="content" width="200">
  349. <template slot-scope="scope">
  350. <div v-if="scope.row.isNew">
  351. <el-input
  352. v-model="scope.row.content"
  353. placeholder="请输入内容"
  354. ></el-input>
  355. </div>
  356. <div v-else>
  357. <span>{{ scope.row.content }}</span>
  358. </div>
  359. </template>
  360. </el-table-column>
  361. <el-table-column label="操作指导" prop="operationGuide">
  362. <template slot-scope="scope">
  363. <div
  364. class="operationGuide_box"
  365. @click="
  366. openOperationGuideDialogDialog(
  367. scope.row.operationGuide,
  368. scope.$index,
  369. scope.row.isNew
  370. )
  371. "
  372. >
  373. <div class="left_content">
  374. <template v-if="scope.row.operationGuide">
  375. <div
  376. v-for="(item, index) in scope.row.operationGuide
  377. .toolList"
  378. :key="item.id"
  379. >{{ index + 1 }}.{{ item.name }}</div
  380. >
  381. </template>
  382. </div>
  383. <div class="right_content">
  384. <template v-if="scope.row.operationGuide">
  385. <div
  386. v-for="(item, index) in scope.row.operationGuide
  387. .procedureList"
  388. :key="item.id"
  389. >{{ index + 1 }}.{{ item.content }}</div
  390. >
  391. </template>
  392. </div>
  393. </div>
  394. </template>
  395. </el-table-column>
  396. <el-table-column label="标准" prop="norm" width="100">
  397. <template slot-scope="scope">
  398. <div v-if="scope.row.isNew">
  399. <el-input
  400. v-model="scope.row.norm"
  401. placeholder="请输入内容"
  402. ></el-input>
  403. </div>
  404. <div v-else>
  405. <span>{{ scope.row.norm }}</span>
  406. </div>
  407. </template>
  408. </el-table-column>
  409. <el-table-column label="操作" width="100">
  410. <template slot-scope="scope">
  411. <el-button
  412. v-if="scope.row.isNew"
  413. type="text"
  414. @click="deleteItem(scope.$index)"
  415. >删除</el-button
  416. >
  417. </template>
  418. </el-table-column>
  419. </el-table>
  420. </div>
  421. </div>
  422. </el-tab-pane>
  423. </el-tabs>
  424. </el-form>
  425. <template v-slot:footer>
  426. <el-button @click="updateVisible(false)">取消</el-button>
  427. <el-button type="primary" @click="save"> 保存 </el-button>
  428. </template>
  429. <!-- 新增设备 -->
  430. <MaterialAdd ref="productRefs" @chooseEquipment="chooseEquipment">
  431. </MaterialAdd>
  432. <!-- -->
  433. <operation-guideDialog ref="operationGuideDialog" @save="saveEdit" />
  434. <!-- 添加规则 -->
  435. <ele-modal
  436. width="800px"
  437. :visible="addDialog"
  438. :append-to-body="true"
  439. title="规则配置"
  440. :close-on-click-modal="false"
  441. @update:visible="closeAdd"
  442. :maxable="true"
  443. >
  444. <el-select
  445. v-model="ruleObj.ruleId"
  446. size="small"
  447. style="width: 100%"
  448. @change="handleRuleNameChange"
  449. :disabled="isBindPlan"
  450. filterable
  451. >
  452. <el-option
  453. v-for="item in ruleNameList"
  454. :key="item.id"
  455. :value="item.id"
  456. :label="item.code + '-' + item.name"
  457. @click.native="ruleChange(item)"
  458. ></el-option>
  459. </el-select>
  460. <template v-slot:footer>
  461. <el-button @click="closeAdd">取消</el-button>
  462. <el-button type="primary" @click="addRule"> 添加 </el-button>
  463. </template>
  464. </ele-modal>
  465. </ele-modal>
  466. </template>
  467. <script>
  468. import { getDetail, getCode } from '@/api/ruleManagement/matter';
  469. import {
  470. getRule,
  471. getCategory,
  472. getAssetList,
  473. saveOrUpdate,
  474. getInfoById
  475. } from '@/api/ruleManagement/plan';
  476. import { getUserPage } from '@/api/system/organization';
  477. import { getTreeByType } from '@/api/classifyManage';
  478. import MaterialAdd from './MaterialAdd.vue';
  479. import OperationGuideDialog from '@/views/rulesManagement/matterRules/components/operationGuideDialog.vue';
  480. import deptSelect from '@/components/CommomSelect/dept-select.vue';
  481. import { pageList } from '@/api/technology/version/version.js';
  482. import {
  483. bomDelete,
  484. saveBatch,
  485. bomTaskList,
  486. bomTaskDelete,
  487. getByTaskId
  488. } from '@/api/material/BOM';
  489. import { getteampage } from '@/api/workforceManagement/team';
  490. import { getFile } from '@/api/system/file';
  491. import { deepClone } from 'ele-admin/lib/utils/core';
  492. export default {
  493. components: {
  494. MaterialAdd,
  495. deptSelect,
  496. OperationGuideDialog
  497. },
  498. props: {
  499. dialogTitle: {
  500. type: String,
  501. default: () => {
  502. return '新增巡检点计划配置';
  503. }
  504. },
  505. visible: {
  506. type: Boolean,
  507. default: false
  508. }
  509. },
  510. data() {
  511. const defaultForm = {
  512. id: null,
  513. code: '',
  514. name: '',
  515. modelType: '',
  516. brandNum: '',
  517. specification: '',
  518. measuringUnit: '',
  519. bomList: []
  520. };
  521. return {
  522. ruleIndex: 0, // 规则index
  523. ruleId: '',
  524. formLabel: '',
  525. isBindPlan: false,
  526. ruleObj: {
  527. ruleId: '',
  528. name: '',
  529. code: '',
  530. equipmentList: []
  531. },
  532. ruleIdList: [],
  533. addForm: {
  534. code: '', // 计划配置单号
  535. name: '', // 计划配置名称
  536. type: 0, // 默认个人
  537. autoOrder: 1, // 自动派单
  538. ruleId: '', // 规则id
  539. ruleName: '', // 规则名称
  540. duration: null, // 计划完成时长
  541. categoryId: '', // 设备类别id
  542. approvalUserId: '', // 审核人id
  543. groupId: '', // 巡点检部门code
  544. executeIdList: [], // 巡点检人员id
  545. executorPhone: '',
  546. status: 1, // 状态
  547. remark: '', // 备注
  548. urgent: '1',
  549. teamId: '', // 班组id
  550. executeUsers: [] // 执行人
  551. },
  552. ruleNameList: [], // 规则列表
  553. uerList: [], // 审核人列表
  554. executorList: [], // 业务人员列表
  555. defaultForm,
  556. // 表单数据
  557. form: {
  558. ...defaultForm
  559. },
  560. versionList: [],
  561. // 表单验证规则
  562. addFormRules: {
  563. name: [
  564. { required: true, message: '请输入计划配置名称', trigger: 'blur' }
  565. ],
  566. autoOrder: [
  567. { required: true, message: '请选择是否自动派单', trigger: 'change' }
  568. ],
  569. ruleId: [
  570. { required: true, message: '请选择规则名称', trigger: 'change' }
  571. ],
  572. duration: [
  573. { required: true, message: '请输入计划完成时长', trigger: 'blur' }
  574. ],
  575. categoryLevelId: [
  576. { required: true, message: '请选择设备分类', trigger: 'change' }
  577. ],
  578. categoryId: [
  579. { required: true, message: '请选择设备类别', trigger: 'change' }
  580. ],
  581. groupId: [
  582. { required: true, message: '请选择部门', trigger: 'change' }
  583. ],
  584. executeIdList: [
  585. { required: true, message: '请选择人员', trigger: 'change' }
  586. ],
  587. teamId: [
  588. { required: true, message: '请选择班组', trigger: 'change' }
  589. ],
  590. urgent: [
  591. { required: true, message: '请选择紧急程度', trigger: 'change' }
  592. ],
  593. type: [{ required: true, message: '请选择', trigger: 'change' }]
  594. },
  595. columns: [
  596. {
  597. type: 'index',
  598. width: 55,
  599. align: 'center'
  600. },
  601. {
  602. label: '子项编号',
  603. prop: 'subCode',
  604. action: 'subCode'
  605. },
  606. {
  607. label: '物料名称',
  608. prop: 'categoryName',
  609. action: 'categoryName'
  610. },
  611. {
  612. label: '是否回收料',
  613. prop: 'isReworkBom',
  614. action: 'isReworkBom',
  615. slot: 'isReworkBom',
  616. width: 95
  617. },
  618. {
  619. label: '物料编码',
  620. prop: 'categoryCode'
  621. },
  622. {
  623. label: '牌号',
  624. prop: 'brandNum'
  625. },
  626. {
  627. label: '型号',
  628. prop: 'modelType'
  629. },
  630. {
  631. label: '数量',
  632. prop: 'count'
  633. },
  634. {
  635. label: '计量单位',
  636. prop: 'unit'
  637. },
  638. {
  639. label: '附件',
  640. slot: 'bomArtFiles',
  641. action: 'bomArtFiles',
  642. minWidth: 100
  643. },
  644. {
  645. label: '单位',
  646. prop: 'weightUnit'
  647. },
  648. {
  649. label: '备注',
  650. prop: 'remark'
  651. }
  652. ],
  653. statusList: [
  654. { label: '草稿', value: -1 },
  655. { label: '失效', value: 0 },
  656. { label: '生效', value: 1 }
  657. ],
  658. // 提交状态
  659. loading: false,
  660. categoryId: null,
  661. current: null,
  662. materialShow: false,
  663. tabsList: [],
  664. tableData: [],
  665. taskId: null,
  666. addDialog: false,
  667. tabsValue: null,
  668. hasCategoryId: false,
  669. getByIdData: {},
  670. modelType: '',
  671. teamAllList: []
  672. };
  673. },
  674. computed: {
  675. // 是否开启响应式布局
  676. styleResponsive() {
  677. return this.$store.state.theme.styleResponsive;
  678. },
  679. dispatchType() {
  680. return (
  681. (this.addForm.autoOrder &&
  682. (this.modelType == 'add' || this.modelType == 'edit')) ||
  683. (!this.addForm.autoOrder && this.modelType == 'dispatch')
  684. );
  685. }
  686. },
  687. watch: {
  688. visible(val) {
  689. if (val) {
  690. this.formLabel = this.dialogTitle.includes('巡点检')
  691. ? '巡点检'
  692. : this.dialogTitle.includes('运行记录')
  693. ? '运行记录'
  694. : this.dialogTitle.includes('保养')
  695. ? '保养'
  696. : this.dialogTitle.includes('检修')
  697. ? '检修'
  698. : '盘点';
  699. // 获取审核人列表数据
  700. this.getUserList();
  701. // 获取规则名称
  702. this._getRuleNameList();
  703. }
  704. }
  705. },
  706. mounted() {
  707. this.getAllTeamList();
  708. this.getUserList({ groupId: '1' });
  709. },
  710. methods: {
  711. // 初始化
  712. async init(type, row, tips) {
  713. console.log(row);
  714. console.log(tips);
  715. this.modelType = type;
  716. if (row) {
  717. this.getInfo(row.id);
  718. } else {
  719. // 获取计划配置单号
  720. this.getOrderCode(tips);
  721. this.addForm = {
  722. code: '', // 计划配置单号
  723. name: '', // 计划配置名称
  724. autoOrder: 1, // 自动派单
  725. type: 0, // 默认个人
  726. ruleId: '', // 规则id
  727. ruleName: '', // 规则名称
  728. duration: null, // 计划完成时长
  729. categoryId: '', // 设备类别id
  730. approvalUserId: '', // 审核人id
  731. groupId: '', // 巡点检部门code
  732. executeIdList: [], // 巡点检人员id
  733. executorPhone: '',
  734. status: 1, // 状态
  735. remark: '', // 备注
  736. urgent: '1',
  737. teamId: '', // 班组id
  738. executeUsers: [] // 执行人
  739. };
  740. this.ruleIdList = [];
  741. this.isBindPlan = false;
  742. this.planRuleEquiList = [];
  743. // this.matterRulesList = [];
  744. }
  745. },
  746. async getAllTeamList() {
  747. const { list } = await getteampage({
  748. pageNum: 1,
  749. size: -1
  750. });
  751. console.log('teamAllList 班组', list);
  752. this.teamAllList = list;
  753. },
  754. teamChange() {
  755. console.log('this.addForm.teamId', this.addForm.teamId);
  756. // 当前班组
  757. const currentTeam = this.teamAllList.find(
  758. (item) => item.id === this.addForm.teamId
  759. );
  760. if (currentTeam) {
  761. // 同步执行人
  762. this.addForm.executeUsers = [
  763. {
  764. teamId: currentTeam.id,
  765. teamName: currentTeam.name
  766. }
  767. ];
  768. }
  769. },
  770. typeChange(v) {
  771. console.log('typeChange', v, this.addForm.executeIdList);
  772. // this.addForm.groupId = '';
  773. // this.addForm.executeIdList = [];
  774. // this.addForm.teamId = '';
  775. // this.addForm.executeUsers = [];
  776. this.$set(this.addForm, 'executeUsers', []);
  777. if (v == 0) {
  778. this.$set(this.addForm, 'groupId', '');
  779. this.$set(this.addForm, 'executeIdList', []);
  780. } else {
  781. this.$set(this.addForm, 'teamId', '');
  782. }
  783. this.$forceUpdate();
  784. },
  785. ruleChange(item) {
  786. this.ruleObj.name = item.name;
  787. this.ruleObj.code = item.code;
  788. },
  789. save() {
  790. console.log(this.addForm);
  791. console.log(this.ruleIdList);
  792. if (this.ruleIdList && this.ruleIdList.length > 0) {
  793. this.$refs.addFormRef.validate(async (valid) => {
  794. console.log(valid);
  795. if (valid) {
  796. // this.addForm.deviceInfo = selectList.map((item) => {
  797. // return {
  798. // substanceId: item.id,
  799. // sparePart: item.sparePart ? item.sparePart : [],
  800. // totalCost: item.totalCost
  801. // };
  802. // });
  803. this.addForm.executeId =
  804. this.addForm.executeIdList &&
  805. this.addForm.executeIdList.toString();
  806. this.addForm.ruleType = this.dialogTitle.includes('巡点检')
  807. ? 1
  808. : this.dialogTitle.includes('保养')
  809. ? 2
  810. : this.dialogTitle.includes('运行记录')
  811. ? 5
  812. : this.dialogTitle.includes('检修')
  813. ? 7
  814. : 4;
  815. console.log(this.ruleIdList);
  816. this.addForm.isBindPlan = this.isBindPlan;
  817. let planConfigAddOrUpdatePOList = this.ruleIdList.map((item) => {
  818. return {
  819. id: item.id,
  820. ruleId: item.ruleId,
  821. ruleName: item.name,
  822. ruleCode: item.code,
  823. categoryId: item.categoryId,
  824. deviceInfo: item.equipmentList.map((item) => {
  825. return {
  826. // substanceId: this.dialogTitle.includes('新增')
  827. // ? item.position[0]?.substanceId
  828. // : item.id,
  829. substanceId: item.id,
  830. // 前端回显字段
  831. id: item.id,
  832. codeNumber: item.codeNumber,
  833. name: item.name,
  834. fixCode: item.fixCode,
  835. categoryId: item.category.categoryLevelId,
  836. categoryName: item.category.categoryLevelName
  837. };
  838. }),
  839. ruleMatters: item.ruleItems
  840. };
  841. });
  842. const planConfigAddOrUpdatePOListIds =
  843. planConfigAddOrUpdatePOList.map((i) => i.id);
  844. console.log(planConfigAddOrUpdatePOList);
  845. let boolen = planConfigAddOrUpdatePOList.every(
  846. (item) => item.deviceInfo.length > 0
  847. );
  848. if (!boolen) {
  849. this.$message.error('请添加设备!');
  850. return false;
  851. }
  852. this.addForm.ruleName = this.ruleIdList
  853. .map((item) => item.name)
  854. .join(',');
  855. this.addForm.ruleCode = this.ruleIdList
  856. .map((item) => item.code)
  857. .join(',');
  858. this.addForm.planConfigAddOrUpdatePOList =
  859. planConfigAddOrUpdatePOList;
  860. this.addForm.ruleId = '0'; // 无效后台验证
  861. let sendMsg = deepClone(this.addForm);
  862. const type = this.dialogTitle.includes('新增') ? '新增' : '编辑';
  863. try {
  864. let res = await saveOrUpdate(sendMsg);
  865. if (res) {
  866. this.$message.success(type + '成功!');
  867. this.$emit('done');
  868. }
  869. } catch (error) {
  870. console.log(error);
  871. this.$message.error(type + '失败!');
  872. }
  873. }
  874. });
  875. } else {
  876. this.$message.error('请添加规则!');
  877. }
  878. },
  879. // 保存操作指导数据
  880. saveEdit(data, index) {
  881. console.log(this.matterRulesList);
  882. console.log(data);
  883. console.log(index);
  884. this.$set(
  885. this.ruleIdList[this.ruleIndex].ruleItems[index],
  886. 'operationGuide',
  887. data
  888. );
  889. },
  890. /* 打开操作手册编辑款 */
  891. openOperationGuideDialogDialog(row, index, isNew) {
  892. console.log(isNew, 'isNew');
  893. if (isNew) {
  894. this.$refs.operationGuideDialog.open(row, index);
  895. }
  896. },
  897. deleteEquipment(index) {
  898. this.ruleIdList[this.ruleIndex].equipmentList.splice(index, 1);
  899. },
  900. deleteItem(index) {
  901. this.ruleIdList[this.ruleIndex].ruleItems.splice(index, 1);
  902. },
  903. addPostscript() {
  904. // console.log(
  905. // 'this.matterRulesList---------------',
  906. // this.matterRulesList
  907. // );
  908. this.ruleIdList[this.ruleIndex].ruleItems.push({
  909. sort: null,
  910. name: '',
  911. content: '',
  912. norm: '',
  913. isNew: true,
  914. operationGuide: {
  915. procedureList: [],
  916. toolList: []
  917. }
  918. });
  919. console.log(this.ruleIdList, '225');
  920. },
  921. async getInfo(id) {
  922. console.log(id);
  923. try {
  924. const res = await getInfoById(id);
  925. console.log('res----------', res);
  926. // this.addForm = res;
  927. this.isBindPlan = res.isBindPlan;
  928. this.categoryEquipment(res.categoryLevelId);
  929. this.ruleIdList = res.planConfigVOList.map((item) => {
  930. return {
  931. id: item.id,
  932. ruleId: item.ruleId,
  933. name: item.ruleName,
  934. code: item.ruleCode,
  935. categoryId: item.categoryId,
  936. equipmentList: item.deviceInfo.map((item) => {
  937. return {
  938. name: item.name,
  939. id: item.id,
  940. fixCode: item.fixCode,
  941. codeNumber: item.codeNumber,
  942. category: {
  943. categoryLevelId: item.categoryId,
  944. categoryLevelName: item.categoryName
  945. }
  946. };
  947. }),
  948. ruleItems: item.ruleMatters
  949. };
  950. });
  951. // 处理回显数据
  952. if (res.type === 0) {
  953. // 个人
  954. res.executeIdList = res.executeUsers.map((item) => item.userId);
  955. let groupIds = res.executeUsers
  956. .map((i) => i.groupId)
  957. .filter((i) => i);
  958. groupIds = Array.from(new Set(groupIds));
  959. if (groupIds.includes('1')) {
  960. // 包含全部部门,置空
  961. res.groupId = '1';
  962. } else {
  963. res.groupId = res.executeUsers?.[0]?.groupId || '1';
  964. }
  965. // this.addForm.teamId = ''
  966. // this.$set(this.addForm, 'teamId', '');
  967. groupIds.map((item) => {
  968. this.searchDeptNodeClick(item);
  969. });
  970. } else {
  971. // 班组
  972. res.teamId = res.executeUsers?.[0]?.teamId || '';
  973. // this.$set(this.addForm, 'groupId', '');
  974. // this.$set(this.addForm, 'executeIdList', []);
  975. // this.addForm.groupId = ''
  976. // this.addForm.executeIdList = []
  977. }
  978. this.tabsValue = this.ruleIdList[0].ruleId;
  979. if (res.groupId) {
  980. const params = { groupId: res.groupId };
  981. this.getUserList(params);
  982. }
  983. this.$set(this, 'addForm', res);
  984. // this._getMatterRulesDetails(res.ruleId);
  985. this.$set(this.addForm, 'code', res.code);
  986. this.$set(this.addForm, 'urgent', JSON.stringify(res.urgent));
  987. // this.$set(this.addForm, 'executeIdList', res.executeId.split(','));
  988. this.$set(this.addForm, 'imageUrl', {});
  989. // console.log(this.rootData);
  990. const rep = await getTreeByType(0);
  991. console.log('sasas', res);
  992. const ids = this.findTopLevelAncestorId(
  993. rep.data,
  994. res.categoryLevelId
  995. );
  996. this.rootId = ids;
  997. // await this._getEquipmentList(res.categoryLevelId, this.isBindPlan);
  998. let keys = [];
  999. res.deviceInfo.map((item) => {
  1000. keys.push(item.substanceId);
  1001. });
  1002. this.$nextTick(() => {
  1003. this.$refs.equiListTree.setCheckedKeys(keys);
  1004. });
  1005. this.clickedTreeNode = true;
  1006. } catch (error) {}
  1007. },
  1008. // 获取设备分类数据
  1009. async categoryEquipment(id) {
  1010. const params = { categoryLevelId: id, pageNum: 1, size: -1 };
  1011. console.log('params==', params);
  1012. const data = await getCategory(params);
  1013. console.log(data);
  1014. this.equipmentList = data.list;
  1015. },
  1016. // 选择设备
  1017. chooseEquipment(data, index, categoryId) {
  1018. this.$set(
  1019. this.ruleIdList[index],
  1020. 'equipmentList',
  1021. this.ruleIdList[index].equipmentList.concat(data)
  1022. );
  1023. this.$set(this.ruleIdList[index], 'categoryId', categoryId);
  1024. console.log(this.ruleIdList);
  1025. },
  1026. // 获取计划配置单号
  1027. async getOrderCode(tips) {
  1028. if (tips.includes('巡点检')) {
  1029. const data = await getCode('patrolconfig_code');
  1030. this.$set(this.addForm, 'code', data);
  1031. }
  1032. if (tips.includes('保养')) {
  1033. const code = await getCode('maintainconfig_code');
  1034. this.$set(this.addForm, 'code', code);
  1035. }
  1036. if (tips.includes('量具送检')) {
  1037. const code = await getCode('quantity_code');
  1038. this.$set(this.addForm, 'code', code);
  1039. }
  1040. if (tips.includes('运行记录')) {
  1041. const code = await getCode('runRecord_code');
  1042. this.$set(this.addForm, 'code', code);
  1043. }
  1044. if (tips.includes('检修')) {
  1045. const code = await getCode('service_code');
  1046. this.$set(this.addForm, 'code', code);
  1047. }
  1048. },
  1049. //选择部门(搜索)
  1050. async searchDeptNodeClick(info, data) {
  1051. console.log('searchDeptNodeClick', info, data);
  1052. if (info) {
  1053. // 根据部门获取人员
  1054. // this.addForm.groupName = data.name;
  1055. const params = { groupId: info };
  1056. await this.getUserList(params);
  1057. // if (this.addForm.type == 1) {
  1058. // this.addForm.executeIdList = this.executorList.map(
  1059. // (item) => item.id
  1060. // );
  1061. // }
  1062. } else {
  1063. this.addForm.groupId = null;
  1064. }
  1065. },
  1066. // 负责人变更 同步执行人列表
  1067. executeIdListChange(v) {
  1068. console.log('executeIdListChange', v);
  1069. this.addForm.executeUsers = this.addForm.executeIdList.map((userId) => {
  1070. const user = this.executorList.find((u) => u.id === userId);
  1071. return {
  1072. userId: user.id,
  1073. userName: user.name,
  1074. groupId: user.groupId,
  1075. groupName: user.groupName
  1076. };
  1077. });
  1078. console.log('this.addForm.executeUsers', this.addForm.executeUsers);
  1079. },
  1080. // 过滤计划完成时长
  1081. formDataDurationTime(value) {
  1082. if (value > 0) {
  1083. this.addForm.duration = value.replace(/^[0]+/, '');
  1084. } else {
  1085. this.addForm.duration = 0;
  1086. }
  1087. },
  1088. // 获取审核人列表、巡点检人员
  1089. async getUserList(params) {
  1090. try {
  1091. let data = { pageNum: 1, size: -1 };
  1092. // 如果传了参数就是获取巡点检人员数据
  1093. if (params) {
  1094. data = Object.assign(data, params);
  1095. }
  1096. const res = await getUserPage(data);
  1097. console.log('res------------', res);
  1098. if (params) {
  1099. this.executorList = res.list;
  1100. } else {
  1101. this.uerList = res.list;
  1102. }
  1103. } catch (error) {}
  1104. },
  1105. // 获取规则名列表
  1106. async _getRuleNameList() {
  1107. const typeMap = {
  1108. 新增巡点检计划配置: 1,
  1109. 编辑巡点检计划配置: 1,
  1110. 新增保养计划配置: 2,
  1111. 编辑保养计划配置: 2,
  1112. 新增量具送检计划配置: 5,
  1113. 编辑量具送检计划配置: 5,
  1114. 新增运行记录配置: 6,
  1115. 编辑运行记录配置: 6,
  1116. 新增检修配置: 7,
  1117. 编辑检修配置: 7
  1118. };
  1119. const ruleType = typeMap[this.dialogTitle];
  1120. if (ruleType) {
  1121. const res = await getRule({
  1122. status: 1,
  1123. type: ruleType,
  1124. pageNum: 1,
  1125. size: -1
  1126. });
  1127. console.log(res, 'resresresresres');
  1128. this.ruleNameList = res?.list || [];
  1129. }
  1130. },
  1131. downloadFile(file) {
  1132. getFile({ objectName: file.storePath }, file.name);
  1133. },
  1134. openEdit(index) {
  1135. this.current = this.form.bomList[index];
  1136. console.log(this.current);
  1137. this.materialShow = true;
  1138. },
  1139. /* 表格数据源 */
  1140. datasource({ page, limit, where }) {
  1141. return [];
  1142. },
  1143. async getVersionList() {
  1144. const res = await pageList({
  1145. pageNum: 1,
  1146. size: 100
  1147. });
  1148. this.versionList = res.list;
  1149. },
  1150. handleAdd(ruleIdList, ruleIdListIndex) {
  1151. this.$refs.productRefs.open(ruleIdList, ruleIdListIndex);
  1152. },
  1153. /* 更新visible */
  1154. updateVisible(value) {
  1155. this.$emit('update:visible', value);
  1156. },
  1157. async getCategoryBomFn(taskId) {
  1158. const res = await getByTaskId(this.categoryId, taskId);
  1159. this.form.bomList = res;
  1160. },
  1161. remove(row) {
  1162. bomDelete([row.id])
  1163. .then((message) => {
  1164. this.$message.success(message);
  1165. this.getCategoryBomFn();
  1166. })
  1167. .catch((e) => {
  1168. this.$message.error(e.message);
  1169. });
  1170. },
  1171. done(taskId) {
  1172. this.materialShow = false;
  1173. this.getCategoryBomFn(taskId);
  1174. },
  1175. handleAddTab() {
  1176. this.tableData = this.tabsList;
  1177. this.addDialog = true;
  1178. },
  1179. handleTab(e) {
  1180. this.ruleIndex = e.index;
  1181. // this.ruleIdList[e.index].ruleItems = this._getMatterRulesDetails(this.ruleId)
  1182. },
  1183. removeTab(targetRuleId) {
  1184. this.$confirm('是否删除当前规则?', '提示', {
  1185. confirmButtonText: '确定',
  1186. cancelButtonText: '取消',
  1187. type: 'warning'
  1188. })
  1189. .then(() => {
  1190. console.log('targetName', targetRuleId);
  1191. console.log('this.ruleIdList', this.ruleIdList);
  1192. this.ruleIdList = this.ruleIdList.filter(
  1193. (item) => item.ruleId != targetRuleId
  1194. );
  1195. console.log('this.ruleIdList', this.ruleIdList);
  1196. this.$nextTick(() => {
  1197. if (this.ruleIdList.length == 1) {
  1198. this.tabsValue = this.ruleIdList[0].ruleId;
  1199. }
  1200. });
  1201. })
  1202. .catch(() => {});
  1203. },
  1204. /*关闭选择参数*/
  1205. closeAdd() {
  1206. this.addDialog = false;
  1207. },
  1208. // 规则名称下拉触发
  1209. handleRuleNameChange(val) {
  1210. this.ruleId = val;
  1211. console.log('val----', val);
  1212. this.getRulesDetails(val);
  1213. },
  1214. async getRulesDetails(val) {
  1215. const res = await getDetail(val);
  1216. console.log('res------', res);
  1217. this.getByIdData = res;
  1218. this.hasCategoryId = res?.categoryId;
  1219. },
  1220. // 封装 - 获取规则下面的详情数据及事项
  1221. async _getMatterRulesDetails(val) {
  1222. const res = await getDetail(val);
  1223. return res.ruleItems;
  1224. // console.log('res------', res);
  1225. // this.matterRulesList = res.ruleItems;
  1226. },
  1227. async addRule() {
  1228. console.log(this.ruleIdList);
  1229. console.log(this.ruleId);
  1230. let boolen = this.ruleIdList.every((item) => {
  1231. return this.ruleId != item.ruleId;
  1232. });
  1233. if (boolen) {
  1234. console.log(this.ruleNameList);
  1235. this.ruleObj.ruleItems = await this._getMatterRulesDetails(
  1236. this.ruleId
  1237. );
  1238. for (let i = 0; i < this.ruleObj.ruleItems.length; i++) {
  1239. const id = this.getByIdData?.categoryId;
  1240. const name = this.getByIdData?.categoryName;
  1241. this.ruleObj.ruleItems[i].categoryId = id;
  1242. this.ruleObj.ruleItems[i].categoryName = name;
  1243. this.ruleObj.ruleItems[i].isNew = true;
  1244. }
  1245. this.ruleIdList.push(deepClone(this.ruleObj));
  1246. console.log('this.ruleIdList--------', this.ruleIdList);
  1247. this.addDialog = false;
  1248. this.$nextTick(() => {
  1249. if (this.ruleIdList.length == 1) {
  1250. this.tabsValue = this.ruleIdList[0].ruleId;
  1251. }
  1252. });
  1253. } else {
  1254. this.$message.error('请误重复添加规则');
  1255. }
  1256. },
  1257. // 保存
  1258. saveBatchFn() {
  1259. let arr = [];
  1260. arr = this.tabsList.map((m) => {
  1261. return {
  1262. taskId: m.id,
  1263. sort: m.sort,
  1264. categoryId: this.categoryId
  1265. };
  1266. });
  1267. saveBatch(arr).then((res) => {
  1268. this.taskListHead();
  1269. });
  1270. },
  1271. taskListHead(isFirst) {
  1272. console.log(isFirst);
  1273. bomTaskList(this.categoryId).then((res) => {
  1274. let arr = [];
  1275. arr = res.map((m) => {
  1276. return {
  1277. oldId: m.id,
  1278. sourceTaskId: m.id,
  1279. id: m.taskId,
  1280. name: m.taskName
  1281. };
  1282. });
  1283. this.tabsList = arr;
  1284. if (isFirst && this.tabsList.length > 0) {
  1285. this.tabsValue = this.tabsList[0].id;
  1286. this.getCategoryBomFn(this.tabsList[0].id);
  1287. }
  1288. });
  1289. }
  1290. }
  1291. };
  1292. </script>
  1293. <style lang="scss" scoped>
  1294. ::v-deep .el-row {
  1295. display: flex;
  1296. flex-wrap: wrap;
  1297. }
  1298. ::v-deep .el-tab_box {
  1299. display: flex;
  1300. margin-top: 10px;
  1301. height: 300px;
  1302. width: 100%;
  1303. .equipmentList_box {
  1304. flex: 1;
  1305. height: 100%;
  1306. margin-right: 10px;
  1307. display: flex;
  1308. flex-direction: column;
  1309. .divider {
  1310. flex: 0 0 50px;
  1311. .title {
  1312. height: 35px;
  1313. }
  1314. }
  1315. .el-table {
  1316. overflow: auto;
  1317. }
  1318. }
  1319. .ruleMatters_box {
  1320. flex: 3;
  1321. height: 100%;
  1322. display: flex;
  1323. flex-direction: column;
  1324. .divider {
  1325. flex: 0 0 50px;
  1326. .title {
  1327. height: 35px;
  1328. }
  1329. }
  1330. .el-table {
  1331. overflow: auto;
  1332. .operationGuide_box {
  1333. width: 100%;
  1334. height: 50px;
  1335. display: flex;
  1336. overflow: hidden;
  1337. cursor: pointer;
  1338. .left_content {
  1339. flex: 0 0 200px;
  1340. padding: 10px;
  1341. box-sizing: border-box;
  1342. border: 1px solid #c0c4cc;
  1343. border-radius: 10px;
  1344. margin-right: 10px;
  1345. overflow-y: auto;
  1346. }
  1347. .right_content {
  1348. flex: 1;
  1349. padding: 10px;
  1350. box-sizing: border-box;
  1351. border: 1px solid #c0c4cc;
  1352. border-radius: 10px;
  1353. overflow-y: auto;
  1354. }
  1355. }
  1356. }
  1357. .el-table::before {
  1358. display: none;
  1359. }
  1360. }
  1361. }
  1362. </style>