index.vue 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873
  1. <template>
  2. <el-dialog
  3. :title="dialogTitle"
  4. :visible.sync="addPatrolConfigDialog"
  5. :before-close="handleClose"
  6. :close-on-click-modal="false"
  7. :close-on-press-escape="false"
  8. v-loading="addDialogLoading"
  9. width="80%"
  10. >
  11. <div class="dialog_body">
  12. <el-form
  13. :model="addForm"
  14. ref="addFormRef"
  15. :rules="addFormRules"
  16. label-width="120px"
  17. >
  18. <el-row>
  19. <el-col :span="8">
  20. <el-form-item label="计划配置单号" prop="code">
  21. <el-input
  22. v-model="addForm.code"
  23. size="small"
  24. placeholder="自动带出"
  25. disabled
  26. ></el-input>
  27. </el-form-item>
  28. </el-col>
  29. <el-col :span="8">
  30. <el-form-item label="计划配置名称" prop="name">
  31. <el-input
  32. v-model="addForm.name"
  33. size="small"
  34. placeholder="请输入"
  35. :disabled="isBindPlan"
  36. ></el-input>
  37. </el-form-item>
  38. </el-col>
  39. <el-col :span="8">
  40. <el-form-item label="自动派单" prop="autoOrder">
  41. <el-select
  42. v-model="addForm.autoOrder"
  43. size="small"
  44. style="width: 100%"
  45. :disabled="isBindPlan"
  46. >
  47. <el-option :value="1" label="是"></el-option>
  48. <el-option :value="0" label="否"></el-option>
  49. </el-select>
  50. </el-form-item>
  51. </el-col>
  52. <el-col :span="8">
  53. <el-form-item label="规则名称" prop="ruleId">
  54. <el-select
  55. v-model="addForm.ruleId"
  56. size="small"
  57. style="width: 100%"
  58. @change="handleRuleNameChange"
  59. :disabled="isBindPlan"
  60. >
  61. <el-option
  62. v-for="item in ruleNameList"
  63. :key="item.id"
  64. :value="item.id"
  65. :label="item.name"
  66. @click.native="addForm.ruleName = item.name"
  67. ></el-option>
  68. </el-select>
  69. </el-form-item>
  70. </el-col>
  71. <el-col :span="8">
  72. <el-form-item label="计划完成时长" prop="duration">
  73. <div style="display: flex">
  74. <el-input
  75. v-model="addForm.duration"
  76. size="small"
  77. placeholder="请输入"
  78. :disabled="isBindPlan"
  79. >
  80. <template #suffix>分钟</template>
  81. </el-input>
  82. </div>
  83. </el-form-item>
  84. </el-col>
  85. <el-col :span="8">
  86. <el-form-item label="设备分类" prop="categoryLevelId">
  87. <ele-tree-select
  88. clearable
  89. :data="classifyTree"
  90. v-model="addForm.categoryLevelId"
  91. placeholder="请选择"
  92. default-expand-all
  93. labelKey="name"
  94. valueKey="id"
  95. @change="chooseClassify"
  96. />
  97. </el-form-item>
  98. </el-col>
  99. <el-col :span="8">
  100. <el-form-item label="设备类别" prop="categoryId">
  101. <el-select
  102. v-model="addForm.categoryId"
  103. size="small"
  104. style="width: 100%"
  105. :disabled="isBindPlan"
  106. >
  107. <el-option
  108. v-for="item in equipmentList"
  109. :key="item.id"
  110. :value="item.id"
  111. :label="item.name"
  112. @click.native="handleEquipmentClassChange(item)"
  113. ></el-option>
  114. </el-select>
  115. </el-form-item>
  116. </el-col>
  117. <el-col :span="8">
  118. <el-form-item label="审核人" prop="approvalUserId">
  119. <el-select
  120. v-model="addForm.approvalUserId"
  121. size="small"
  122. clearable
  123. style="width: 100%"
  124. :disabled="isBindPlan"
  125. >
  126. <el-option
  127. v-for="item in uerList"
  128. :key="item.id"
  129. :value="item.id"
  130. :label="item.name"
  131. ></el-option>
  132. </el-select>
  133. </el-form-item>
  134. </el-col>
  135. <el-col :span="8" v-if="addForm.autoOrder">
  136. <el-form-item :label="formLabel + '部门'" prop="groupId">
  137. <ele-tree-select
  138. clearable
  139. :data="deptData"
  140. v-model="addForm.groupId"
  141. placeholder="请选择"
  142. default-expand-all
  143. labelKey="name"
  144. valueKey="id"
  145. @change="searchDeptNodeClick"
  146. />
  147. </el-form-item>
  148. </el-col>
  149. <el-col :span="8" v-if="addForm.autoOrder">
  150. <el-form-item :label="formLabel + '人员'" prop="executeIdList">
  151. <el-select
  152. v-model="addForm.executeIdList"
  153. size="small"
  154. style="width: 100%"
  155. :disabled="isBindPlan"
  156. multiple
  157. >
  158. <el-option
  159. v-for="item in executorList"
  160. :key="item.id"
  161. :value="item.id"
  162. :label="item.name"
  163. ></el-option>
  164. </el-select>
  165. </el-form-item>
  166. </el-col>
  167. <el-col :span="8">
  168. <el-form-item label="紧急程度" prop="urgent">
  169. <DictSelection dictName="紧急程度" clearable v-model="addForm.urgent">
  170. </DictSelection>
  171. </el-form-item>
  172. </el-col>
  173. <el-col :span="8">
  174. <el-form-item label="状态" prop="status">
  175. <el-switch
  176. v-model="addForm.status"
  177. active-text="开"
  178. inactive-text="关"
  179. :active-value="1"
  180. :inactive-value="0"
  181. />
  182. </el-form-item>
  183. </el-col>
  184. <el-col :span="16">
  185. <el-form-item label="备注" prop="remark">
  186. <el-input
  187. type="textarea"
  188. resize="none"
  189. v-model="addForm.remark"
  190. :rows="2"
  191. placeholder="请详细说明"
  192. size="small"
  193. :disabled="isBindPlan"
  194. ></el-input>
  195. </el-form-item>
  196. </el-col>
  197. </el-row>
  198. <!-- 设备分类 -->
  199. <div class="equipment_box">
  200. <div class="left_aside">
  201. <div class="equipment_list_title">设备列表</div>
  202. <div class="equipment_tree">
  203. <el-tree
  204. :data="planRuleEquiList"
  205. :props="defaultProps"
  206. ref="equiListTree"
  207. highlight-current
  208. node-key="id"
  209. @node-click="handleNodeClick"
  210. :disabled="isBindPlan"
  211. show-checkbox
  212. ></el-tree>
  213. </div>
  214. </div>
  215. <div class="right_aside">
  216. <div class="equipment_info">
  217. <div class="item_info">
  218. <span class="item_label">设备编码</span>
  219. <span class="item_value">{{ equipmentInfo.equiCode }}</span>
  220. </div>
  221. <div class="item_info">
  222. <span class="item_label">设备名称</span>
  223. <span class="item_value">{{ equipmentInfo.equiName }}</span>
  224. </div>
  225. <div class="item_info">
  226. <span class="item_label">设备型号</span>
  227. <span class="item_value">{{ equipmentInfo.equiModel }}</span>
  228. </div>
  229. <div class="item_info">
  230. <span class="item_label">设备位置</span>
  231. <span class="item_value">{{ equipmentInfo.equiLocation }}</span>
  232. </div>
  233. </div>
  234. <!-- 添加操作事项 -->
  235. <div>
  236. <el-button type="text">操作事项</el-button>
  237. <el-table
  238. :data="matterRulesList"
  239. border
  240. >
  241. <el-table-column label="序号" align="center" width="60">
  242. <template slot-scope="scope">
  243. <span>{{ scope.$index + 1 }}</span>
  244. </template>
  245. </el-table-column>
  246. <el-table-column label="事项" align="center" prop="name">
  247. </el-table-column>
  248. <el-table-column label="内容" align="center" prop="content">
  249. </el-table-column>
  250. <el-table-column label="标准" align="center" prop="norm">
  251. </el-table-column>
  252. </el-table>
  253. </div>
  254. <!-- 添加备品备件 -->
  255. <div v-if="dialogTitle.includes('保养')">
  256. <el-button type="text" @click="addSpareItems" :disabled="isBindPlan"
  257. >添加备品备件</el-button
  258. >
  259. <el-table
  260. :data="planRuleEquiList[currentEquItemIndex]&&planRuleEquiList[currentEquItemIndex].sparePart"
  261. height="300"
  262. :key='currentEquItemIndex'
  263. border
  264. >
  265. <el-table-column label="序号" align="center" width="60">
  266. <template slot-scope="scope">
  267. <span>{{ scope.$index + 1 }}</span>
  268. </template>
  269. </el-table-column>
  270. <el-table-column label="备件名称" align="center" prop="name">
  271. </el-table-column>
  272. <el-table-column label="规格型号" align="center" prop="model">
  273. </el-table-column>
  274. <el-table-column label="所需数量" align="center" prop="num">
  275. <template slot-scope="scope">
  276. <el-input
  277. v-model.number="scope.row.num"
  278. size="small"
  279. oninput="value=value.replace(/[^\d]/g,'')"
  280. style="width: 100%"
  281. placeholder="输入数量"
  282. @input="changeNum"
  283. ></el-input>
  284. </template>
  285. </el-table-column>
  286. <el-table-column label="单位" align="center" prop="measuringUnit">
  287. </el-table-column>
  288. <el-table-column label="费用" align="center">
  289. <template slot-scope="scope">
  290. {{scope.row.num*scope.row.univalence?scope.row.num*scope.row.univalence:'0'}}{{scope.row.univalenceUnit=='wanyuan'?'万元':'元'}}
  291. </template>
  292. </el-table-column>
  293. <el-table-column label="操作" align="center" width="70">
  294. <template slot-scope="scope">
  295. <el-button
  296. type="text"
  297. @click="handleDeleteSpareItem(scope.$index)"
  298. :disabled="isBindPlan"
  299. >删除</el-button
  300. >
  301. </template>
  302. </el-table-column>
  303. </el-table>
  304. <div style="text-align: center">备件总费用:
  305. {{planRuleEquiList[currentEquItemIndex]&&planRuleEquiList[currentEquItemIndex].totalCost?planRuleEquiList[currentEquItemIndex].totalCost:'-'}}
  306. </div>
  307. </div>
  308. </div>
  309. </div>
  310. </el-form>
  311. </div>
  312. <div slot="footer" class="dialog_footer">
  313. <el-button size="small" type="primary" @click="submit">提交</el-button>
  314. <el-button size="small" @click="handleClose">关闭</el-button>
  315. </div>
  316. <AddSpareDialog
  317. ref="addSpareDialogRef"
  318. :selectedSpare="selectedSpare"
  319. @submit="spareItemSelectSubmit"
  320. />
  321. </el-dialog>
  322. </template>
  323. <script>
  324. import RuleItemSelection from '@/components/ruleItemSelection'
  325. import AddSpareDialog from '@/components/addSpareDialog'
  326. import {deepClone} from "@/utils"
  327. import { getRule , getCategory , getAssetList , saveOrUpdate , getInfoById } from '@/api/ruleManagement/plan';
  328. import { getDetail , getCode } from '@/api/ruleManagement/matter';
  329. import { listOrganizations , getUserPage } from '@/api/system/organization';
  330. import { getTreeByType } from '@/api/classifyManage'
  331. export default {
  332. name: 'addPatrolConfigDialog',
  333. components: { RuleItemSelection, AddSpareDialog },
  334. props: {
  335. dialogTitle: {
  336. type: String,
  337. default: () => {
  338. return '新增巡点检计划配置'
  339. }
  340. },
  341. isBindPlan: {
  342. type: Boolean,
  343. default: function () {
  344. return false
  345. }
  346. },
  347. },
  348. data () {
  349. return {
  350. defaultProps: {
  351. label: 'showName'
  352. },
  353. addPatrolConfigDialog: false,
  354. matterRulesList: [], // 选择规则名称的时候,获取的事项
  355. equipmentInfo: {},
  356. clickedTreeNode: false,
  357. selectedMatter: [],
  358. selectedSpare: [],
  359. uerList: [],
  360. deptList: [],
  361. executorList: [],
  362. currentEquItemIndex: 0,
  363. formLabel: '',
  364. treeData:[],
  365. addForm: {
  366. code:'', // 计划配置单号
  367. name: '', // 计划配置名称
  368. autoOrder: 1, // 自动派单
  369. ruleId: '', // 规则id
  370. ruleName: '', // 规则名称
  371. duration: null, // 计划完成时长
  372. categoryId: '', // 设备类别id
  373. approvalUserId: '', // 审核人id
  374. groupId: '', // 巡点检部门code
  375. executeIdList: [], // 巡点检人员id
  376. executorPhone: '',
  377. status: 1, // 状态
  378. remark: '', // 备注
  379. urgent:'',
  380. bizType:0
  381. },
  382. // 计划规则设备列表
  383. planRuleEquiList: [
  384. {
  385. equiTypeId: '', // 设备分类Id
  386. equiTypeName: '', // 设备分类名字
  387. equiCode: '', // 设备编码 equCode
  388. equiName: '', // 设备名称 name
  389. equiModel: '', // 设备型号 specifications
  390. equiLocation: '', // 设备位置
  391. equiLocationCode: '', // 设备位置code
  392. // 设备备品备件 - 巡点检不需要备品备件,保养需要
  393. sparePart: [ ],
  394. totalCost:0,
  395. }
  396. ],
  397. addFormRules: {
  398. name: [
  399. { required: true, message: '请输入计划配置名称', trigger: 'blur' }
  400. ],
  401. autoOrder: [
  402. { required: true, message: '请选择是否自动派单', trigger: 'change' }
  403. ],
  404. ruleId: [
  405. { required: true, message: '请选择规则名称', trigger: 'change' }
  406. ],
  407. duration: [
  408. { required: true, message: '请输入计划完成时长', trigger: 'blur' }
  409. ],
  410. categoryLevelId:[
  411. { required: true, message: '请选择设备分类', trigger: 'change' }
  412. ],
  413. categoryId: [
  414. { required: true, message: '请选择设备类别', trigger: 'change' }
  415. ],
  416. groupId: [
  417. { required: true, message: '请选择巡点检部门', trigger: 'change' }
  418. ],
  419. executeIdList: [
  420. { required: true, message: '请选择巡点检人员', trigger: 'change' }
  421. ],
  422. urgent: [
  423. { required: true, message: '请选择紧急程度', trigger: 'change' }
  424. ],
  425. },
  426. ruleNameList:[],
  427. addDialogLoading:false,
  428. equipmentList:[],
  429. deptData:[], //部门树
  430. classifyTree:[], //设备分类树
  431. rootId:null,
  432. }
  433. },
  434. computed: {
  435. },
  436. watch: {
  437. addPatrolConfigDialog (val) {
  438. if (val) {
  439. this.formLabel = this.dialogTitle.includes('巡点检')
  440. ? '巡点检'
  441. : this.dialogTitle.includes('保养')
  442. ? '保养'
  443. : '盘点'
  444. // 获取审核人列表数据
  445. this.getUserList()
  446. // 获取部门
  447. this.getDeptList()
  448. // 获取规则名称
  449. this._getRuleNameList()
  450. // 获取设备分类树
  451. this.getClassifyTree()
  452. }
  453. },
  454. },
  455. created(){
  456. },
  457. methods: {
  458. async init(row,tips){
  459. if(row){
  460. this.getInfo(row.id)
  461. }else{
  462. // 获取计划配置单号
  463. this.getOrderCode(tips)
  464. this.planRuleEquiList = []
  465. this.matterRulesList = []
  466. }
  467. },
  468. async getInfo(id){
  469. const res = await getInfoById(id)
  470. this.addForm = res
  471. this.categoryEquipment(res.categoryLevelId)
  472. const params = { groupId: res.groupId }
  473. this.getUserList(params)
  474. this._getEquipmentList(res.categoryId)
  475. this._getMatterRulesDetails(res.ruleId)
  476. this.$set(this.addForm,'code',res.code)
  477. this.$set(this.addForm,'urgent', JSON.stringify(res.urgent) )
  478. this.$set(this.addForm,'executeIdList',res.executeId.split(','))
  479. this.$set(this.addForm,'imageUrl',{})
  480. let keys = []
  481. res.deviceInfo.map(item=>{
  482. keys.push(item.substanceId)
  483. })
  484. this.$nextTick(() => {
  485. this.$refs.equiListTree.setCheckedKeys(keys)
  486. })
  487. this.clickedTreeNode = true
  488. },
  489. handleClose () {
  490. this.addPatrolConfigDialog = false
  491. this.$refs.addFormRef.resetFields()
  492. if (this.$refs.searchTree) {
  493. this.$refs.searchTree.clearHandle()
  494. }
  495. this.currentEquItemIndex = 0
  496. this.equipmentInfo = {}
  497. this.addForm = {
  498. code:'', // 计划配置单号
  499. name: '', // 计划配置名称
  500. autoOrder: 1, // 自动派单
  501. ruleId: '', // 规则id
  502. duration: null, // 计划完成时长
  503. categoryId: '', // 设备类别
  504. approvalUserId: '', // 审核人id
  505. groupId: '', // 巡点检部门code
  506. executeIdList: [], // 巡点检人员id
  507. executorPhone: '',
  508. status: 1, // 状态
  509. remark: '', // 备注
  510. urgent:'',
  511. bizType:0
  512. }
  513. this.equipmentList = []
  514. },
  515. // 设备分类选择
  516. async handleEquipmentClassChange (item) {
  517. this.clickedTreeNode = true
  518. this.equipmentInfo = {}
  519. this._getEquipmentList(item.id)
  520. },
  521. // 封装 - 获取设备分类列表
  522. async _getEquipmentList (val) {
  523. const params = { pageNum: 1,size: -1, categoryId: val, rootCategoryLevelId: this.rootId }
  524. try {
  525. const res = await getAssetList(params)
  526. this.planRuleEquiList = res.list
  527. this.planRuleEquiList.map(item=>{
  528. item.showName = item.name+'('+item.code+')'
  529. })
  530. this.currentEquItemIndex = 0
  531. const item = this.planRuleEquiList[0]
  532. const { equiLocation, equiLocationCode } = this.getEquiLocation(item)
  533. this.$nextTick(() => {
  534. this.$refs.equiListTree.setCurrentKey(item.id)
  535. this.equipmentInfo = {
  536. equiTypeId: this.addForm.categoryId,
  537. equiCode: item.code,
  538. equiName: item.name,
  539. equiModel: item.category.modelType,
  540. equiLocation: equiLocation,
  541. equiLocationCode: equiLocationCode
  542. }
  543. this.currentEquItemIndex = 0
  544. this.planRuleEquiList[0]['equiLocation'] = equiLocation
  545. this.planRuleEquiList[0]['equiLocationCode'] = equiLocationCode
  546. // 对比详情返回的数据和设备分类下面所有的设备列表,将sparePart同步过去
  547. for (let i = 0; i < this.planRuleEquiList.length; i++) {
  548. for (let j = 0; j < this.addForm.deviceInfo.length; j++) {
  549. if ( this.planRuleEquiList[i].code === this.addForm.deviceInfo[j].substanceCode ) {
  550. this.planRuleEquiList[i]['sparePart'] = this.addForm.deviceInfo[j]['sparePart']
  551. break
  552. }
  553. }
  554. }
  555. })
  556. } catch (error) {
  557. this.planRuleEquiList = []
  558. }
  559. },
  560. // 获取审核人列表、巡点检人员
  561. async getUserList (params) {
  562. try {
  563. let data = { pageNum: 1 ,size:-1 }
  564. // 如果传了参数就是获取巡点检人员数据
  565. if (params) {
  566. data = Object.assign(data, params)
  567. }
  568. const res = await getUserPage(data)
  569. if (params) {
  570. this.executorList = res.list
  571. } else {
  572. this.uerList = res.list
  573. }
  574. } catch (error) {}
  575. },
  576. // 获取部门列表数据
  577. async getDeptList () {
  578. try {
  579. let list = await listOrganizations()
  580. this.deptData = this.$util.toTreeData({
  581. data: list,
  582. idField: 'id',
  583. parentIdField: 'parentId'
  584. });
  585. } catch (error) {}
  586. },
  587. //选择部门(搜索)
  588. searchDeptNodeClick (info) {
  589. if (info) {
  590. // 根据部门获取人员
  591. const params = { groupId: info }
  592. this.getUserList(params)
  593. } else {
  594. this.addForm.groupId = null
  595. }
  596. },
  597. // 获取设备分类树
  598. async getClassifyTree(){
  599. const res = await getTreeByType(1)
  600. this.classifyTree = res.data
  601. this.rootId = res.data[0].id
  602. },
  603. // 分类树的选择
  604. chooseClassify(val){
  605. this.categoryEquipment(val)
  606. },
  607. // 获取设备分类数据
  608. async categoryEquipment(id){
  609. const params = {categoryLevelId:id,pageNum:1,size:-1}
  610. const data = await getCategory(params)
  611. this.equipmentList = data.list
  612. },
  613. // 获取计划配置单号
  614. async getOrderCode (tips) {
  615. if(tips.includes('巡点检')){
  616. const data = await getCode('patrolconfig_code');
  617. this.$set(this.addForm, 'code', data);
  618. }
  619. if(tips.includes('保养')){
  620. const code = await getCode('maintainconfig_code');
  621. this.$set(this.addForm, 'code', code);
  622. }
  623. },
  624. // 封装 - 获取设备位置名称和code方法
  625. getEquiLocation(data) {
  626. // 设备位置名称
  627. const path = data.position[0].path
  628. const arry = []
  629. path.map(item=>{
  630. arry.push(item.name)
  631. })
  632. const equiLocation = arry.join('/')
  633. // 设备位置编码
  634. const equiLocationCode = data.position[0].pathIds
  635. return { equiLocation, equiLocationCode }
  636. },
  637. // 设备列表树点击
  638. handleNodeClick (data, node) {
  639. const { equiLocation, equiLocationCode } = this.getEquiLocation(data)
  640. this.equipmentInfo = {
  641. equiCode: data.code,
  642. equiName: data.name,
  643. equiId: data.id,
  644. equiModel: data.category.modelType,
  645. equiLocation: equiLocation,
  646. equiLocationCode: equiLocationCode
  647. }
  648. // 保存当前点击的设备列表某节点的index,在添加操作事项的时候,可以将事项list放到对应的节点对象中,以及切换节点的时候回显事项list
  649. this.currentEquItemIndex = this.planRuleEquiList.findIndex(
  650. item => item.code === data.code
  651. )
  652. this.clickedTreeNode = true
  653. this.planRuleEquiList[this.currentEquItemIndex]['equiLocation'] = equiLocation
  654. this.planRuleEquiList[this.currentEquItemIndex]['equiLocationCode'] = equiLocationCode
  655. },
  656. // 获取规则名列表
  657. async _getRuleNameList () {
  658. if(this.dialogTitle==='新增保养计划配置'||this.dialogTitle==='编辑保养计划配置'){
  659. const res = await getRule({type:2,pageNum:1,size:-1})
  660. if (res.list) {
  661. this.ruleNameList = res.list || []
  662. }
  663. }
  664. if (this.dialogTitle==='新增巡点检计划配置'||this.dialogTitle==='编辑巡点检计划配置'){
  665. const res = await getRule({type:1,pageNum:1,size:-1})
  666. if (res.list) {
  667. this.ruleNameList = res.list || []
  668. }
  669. }
  670. },
  671. // 规则名称下拉触发
  672. handleRuleNameChange (val) {
  673. this._getMatterRulesDetails(val)
  674. },
  675. // 封装 - 获取规则下面的详情数据及事项
  676. async _getMatterRulesDetails (val) {
  677. const res = await getDetail(val)
  678. this.matterRulesList = res.ruleItems
  679. },
  680. // 添加备品备件
  681. addSpareItems () {
  682. if (!this.clickedTreeNode) {
  683. return this.$message.warning('请选择设备分类!')
  684. }
  685. this.$refs.addSpareDialogRef.open()
  686. if (this.planRuleEquiList[this.currentEquItemIndex]['sparePart']) {
  687. this.selectedSpare = this.planRuleEquiList[this.currentEquItemIndex]['sparePart']
  688. } else {
  689. this.selectedSpare = []
  690. }
  691. console.log('this.selectedSpare',this.selectedSpare)
  692. },
  693. // 从备品备件弹窗将数据丢到备品备件配置
  694. spareItemSelectSubmit (list) {
  695. this.planRuleEquiList[this.currentEquItemIndex]['sparePart'] = list.map(item => {
  696. return {
  697. name: item.name,
  698. model: item.category.modelType,
  699. num: item.num,
  700. univalenceUnit: item.category.univalenceUnit,
  701. univalence: item.category.univalence,
  702. measuringUnit:item.category.measuringUnit,
  703. code:item.code,
  704. id:item.id
  705. }
  706. })
  707. this.$forceUpdate()
  708. },
  709. // 删除备品备件
  710. handleDeleteSpareItem (index) {
  711. this.planRuleEquiList[this.currentEquItemIndex][
  712. 'sparePart'
  713. ].splice(index, 1)
  714. this.changeNum()
  715. },
  716. // 改变input数据重新计算总费用
  717. changeNum(){
  718. let applayList = this.planRuleEquiList[this.currentEquItemIndex].sparePart
  719. let total = 0
  720. applayList.map(item=>{
  721. if(item.hasOwnProperty('num')&&item.num!=''){
  722. switch (item.univalenceUnit) {
  723. case 'wanyuan': {
  724. item.chengs = 10000
  725. break;
  726. }
  727. case 'yuan': {
  728. item.chengs = 1
  729. break;
  730. }
  731. default:
  732. break;
  733. }
  734. total = total + item.num*item.univalence*item.chengs
  735. }
  736. })
  737. this.$set(this.planRuleEquiList[this.currentEquItemIndex],'totalCost',total)
  738. },
  739. // 提交
  740. submit () {
  741. this.$refs.addFormRef.validate(async valid => {
  742. if (valid) {
  743. try {
  744. const selectList = this.$refs.equiListTree.getCheckedNodes();
  745. this.addForm.deviceInfo = selectList.map(
  746. item => {
  747. const { equiLocation, equiLocationCode } = this.getEquiLocation(item)
  748. return {
  749. substanceName: item.name,
  750. substanceId: item.id,
  751. sparePart: item.sparePart?item.sparePart:[],
  752. substanceCode: item.code,
  753. mode: item.category.modelType,
  754. position: equiLocation
  755. }
  756. }
  757. )
  758. this.addForm.executeId = this.addForm.executeIdList.join(',')
  759. this.addForm.ruleType = this.dialogTitle.includes('巡点检')
  760. ? 1
  761. : this.dialogTitle.includes('保养')
  762. ? 2
  763. : 3
  764. const res = await saveOrUpdate(this.addForm)
  765. if (res) {
  766. const type = this.dialogTitle.includes('新增') ? '新增' : '编辑'
  767. this.handleClose()
  768. this.$message.success(type + '成功!')
  769. this.$emit('done')
  770. }
  771. } catch (error) {}
  772. }
  773. })
  774. }
  775. }
  776. }
  777. </script>
  778. <style lang="scss" scoped>
  779. ::v-deep .el-form {
  780. .el-form-item {
  781. margin-bottom: 14px;
  782. }
  783. .el-form-item__error {
  784. padding-top: 0;
  785. }
  786. }
  787. .equipment_box {
  788. display: flex;
  789. .left_aside {
  790. width: 300px;
  791. border: 1px solid #797979;
  792. margin-right: 5px;
  793. .equipment_list_title {
  794. height: 34px;
  795. line-height: 34px;
  796. text-align: center;
  797. background-color: #d7d7d7;
  798. color: #000;
  799. font-weight: 700;
  800. }
  801. .equipment_tree {
  802. height: 510px;
  803. overflow: auto;
  804. }
  805. ::v-deep .el-tree-node__expand-icon.el-icon-caret-right {
  806. padding: 0;
  807. }
  808. ::v-deep
  809. .el-tree--highlight-current
  810. .el-tree-node.is-current
  811. > .el-tree-node__content {
  812. background-color: #d7f1fd !important;
  813. }
  814. }
  815. .right_aside {
  816. flex: 1;
  817. border: 1px solid #797979;
  818. padding: 10px;
  819. .equipment_info {
  820. display: flex;
  821. flex-wrap: wrap;
  822. border: 1px solid #ddd;
  823. .item_info {
  824. width: 33%;
  825. height: 34px;
  826. line-height: 34px;
  827. display: flex;
  828. .item_label {
  829. width: 90px;
  830. text-align: center;
  831. background-color: #f2f2f2;
  832. font-weight: 700;
  833. }
  834. .item_value {
  835. border-bottom: 1px solid #f2f2f2;
  836. flex: 1;
  837. padding-left: 5px;
  838. }
  839. &:last-child {
  840. width: 100%;
  841. .item_value {
  842. border: 0;
  843. }
  844. }
  845. }
  846. }
  847. }
  848. }
  849. .dialog_footer {
  850. text-align: center;
  851. }
  852. </style>