programRulesDialog.vue 44 KB

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