programRulesDialog.vue 39 KB

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