index.vue 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742
  1. <template>
  2. <div class="container treebox">
  3. <el-tree id="mainLeft" class="filter-tree" :data="treeData" :props="defaultProps" @node-click="handTreeClick" :highlight-current="true" node-key="depotCode" default-expand-all ref="userManageTree" :expand-on-click-node="false" :filter-node-method="filterNode"></el-tree>
  4. <div id="mainRight" v-if=" this.dhierarchy != 1">
  5. <div class="select">
  6. <el-form>
  7. <el-form-item label="选择具体的审批流程">
  8. <el-select v-model="type" @change="headChange()">
  9. <el-option v-for="item in process" :key="item.type" :label="item.label" :value="item.type" />
  10. </el-select>
  11. </el-form-item>
  12. </el-form>
  13. </div>
  14. <div class="table">
  15. <el-table :data="tableData" style="width: 100%" border :header-cell-style="{ background: '#f8f8f8' }">
  16. <el-table-column label="工作项" prop="title" align="center" />
  17. <el-table-column label="处理角色" align="center" prop="content">
  18. <template slot-scope="scope">
  19. <div v-if="scope.row.content == 0">保管员</div>
  20. <!-- <div v-else>{{scope.row}}</div> -->
  21. <el-select v-else v-model="scope.row.content" placeholder="请选择审批人">
  22. <el-option v-for="item in scope.row.approverSelect" :key="item.uId" :label="item.personnelName" :value="item.uId" />
  23. </el-select>
  24. </template>
  25. </el-table-column>
  26. </el-table>
  27. </div>
  28. <div class="btns">
  29. <el-button type="savebtn" @click="btnSave()" :loading="loading">保存</el-button>
  30. </div>
  31. </div>
  32. </div>
  33. </template>
  34. <script>
  35. // import {tableHeaderColor} from "@/utils/tableHeaderColor"
  36. import { getUser } from "@/utils/auth"
  37. import {
  38. roleList,
  39. approverSubmit,
  40. checkList
  41. } from "@/api/system/userManagement/approver"
  42. import { findbyTreeData } from "@/api/branchoff/index.js"
  43. export default {
  44. name: "ApproverManagement",
  45. data() {
  46. return {
  47. dhierarchy:'',
  48. defaultProps: {
  49. children: "children",
  50. label: "depotName",
  51. value: "depotCode"
  52. },
  53. treetotal: [],
  54. treeData: [],
  55. //进度条
  56. loading: false,
  57. //存储用户信息
  58. userInfo: {},
  59. //库id
  60. depotId: 1,
  61. roleArr: [],
  62. //33--主管科长 35---分管副总经理 34---总经理 37--分公司主管
  63. //角色id
  64. rolesId: "33,34,35,37",
  65. //初始化审批人下拉选
  66. approverSelect: [],
  67. // 表格数据初始化
  68. tableData: [],
  69. // 头部下拉选的值
  70. type: "tf",
  71. loading: false,
  72. // 流程下拉选
  73. process: [
  74. {
  75. label: "机械通风",
  76. type: "tf"
  77. },
  78. {
  79. label: "熏蒸计划",
  80. type: "xzjh",
  81. },
  82. {
  83. label: "熏蒸散气",
  84. type: "xzsq",
  85. },
  86. {
  87. label: "药剂采购",
  88. type: "yjcg"
  89. },
  90. {
  91. label: "药剂领用",
  92. type: "yjly"
  93. },
  94. {
  95. label: "设备采购",
  96. type: "sbcg",
  97. },
  98. {
  99. label: "设备领用",
  100. type: "sbly",
  101. },
  102. {
  103. label: "设备归还",
  104. type: "sbgh",
  105. },
  106. {
  107. label: "设备维修",
  108. type: "sbwx",
  109. },
  110. {
  111. label: "设备报废",
  112. type: "sbbf",
  113. },
  114. {
  115. label: "设施维修计划",
  116. type: "sswxjh",
  117. },
  118. {
  119. label: "设施维修预算",
  120. type: "sswxys",
  121. },
  122. ],
  123. // 机械通风数据
  124. meVentilation: [
  125. {
  126. step: "1",
  127. form: "container",
  128. title: "制定通风方案",
  129. content: 0
  130. },
  131. {
  132. step: "2",
  133. title: "主管科长审批",
  134. content: null,
  135. approverSelect: []
  136. },
  137. {
  138. step: "3",
  139. title: "分管副总经理审批",
  140. content: null,
  141. approverSelect: []
  142. },
  143. {
  144. step: "4",
  145. title: "通风方案实施",
  146. content: 0
  147. }
  148. ],
  149. // 熏蒸数据
  150. fumigation: [
  151. {
  152. step: "1",
  153. type: "container",
  154. title: "制定熏蒸计划",
  155. content: "保管员"
  156. },
  157. {
  158. step: "2",
  159. type: "select",
  160. title: "熏蒸计划主管科长审批",
  161. content: ""
  162. },
  163. {
  164. step: "3",
  165. type: "select",
  166. title: "熏蒸计划分管副总经理审批",
  167. content: ""
  168. },
  169. {
  170. step: "4",
  171. type: "container",
  172. title: "熏蒸计划总经理审批",
  173. content: "总经理(刘亮)"
  174. },
  175. {
  176. step: "5",
  177. type: "select",
  178. title: "熏蒸计划分公司主管处室审批",
  179. content: ""
  180. },
  181. {
  182. step: "6",
  183. type: "container",
  184. title: "熏蒸计划报备与实施",
  185. content: "保管员"
  186. },
  187. ],
  188. fumigation1: [
  189. {
  190. step: "7",
  191. type: "container",
  192. title: "提交散气作业申请",
  193. content: "保管员"
  194. },
  195. {
  196. step: "8",
  197. type: "select",
  198. title: "散气作业主管科长审批",
  199. content: ""
  200. },
  201. {
  202. step: "9",
  203. type: "select",
  204. title: "散气作业分管副总经理",
  205. content: ""
  206. }
  207. ],
  208. // 药剂采购
  209. drugPurchase: [
  210. {
  211. step: "1",
  212. content: 0,
  213. title: "采购申请提交"
  214. },
  215. {
  216. step: "2",
  217. title: "主管科长审批",
  218. content: null
  219. },
  220. {
  221. step: "3",
  222. title: "分管副总经理审批",
  223. content: null
  224. },
  225. {
  226. step: "4",
  227. title: "总经理审批",
  228. content: null
  229. },
  230. {
  231. step: "5",
  232. title: " 分公司主管处室审批",
  233. content: null
  234. }
  235. ],
  236. // 药剂领用
  237. drugCollect: [
  238. {
  239. step: "1",
  240. title: "填写药品领用单",
  241. content: 0
  242. },
  243. {
  244. step: "2",
  245. title: "主管科长审批",
  246. content: null
  247. },
  248. {
  249. step: "3",
  250. title: "分管副总经理审批",
  251. content: null
  252. },
  253. {
  254. step: "4",
  255. title: "药剂领用",
  256. content: 0
  257. }
  258. ],
  259. // 设备采购
  260. devicePurchase: [
  261. {
  262. step: "1",
  263. type: "container",
  264. title: "制定采购计划",
  265. content: "设备设施保管员"
  266. },
  267. {
  268. step: "2",
  269. type: "select",
  270. title: "主管科长审批",
  271. content: ""
  272. },
  273. {
  274. step: "3",
  275. type: "select",
  276. title: "分管副总经理审批",
  277. content: ""
  278. },
  279. {
  280. step: "4",
  281. type: "container",
  282. title: "总经理审批",
  283. content: "总经理(张立)"
  284. },
  285. {
  286. step: "5",
  287. type: "select",
  288. title: "分公司审批",
  289. content: ""
  290. },
  291. {
  292. step: "6",
  293. type: "container",
  294. title: "采购计划执行",
  295. content: "设备设施保管员"
  296. }
  297. ],
  298. // 设备领用
  299. deviceCollect: [
  300. {
  301. step: "1",
  302. type: "container",
  303. title: "制定领用申请",
  304. content: ""
  305. },
  306. {
  307. step: "2",
  308. type: "select",
  309. title: "主管科长审批",
  310. content: ""
  311. }
  312. ],
  313. // 设备归还
  314. devicetReturn: [
  315. {
  316. step: "1",
  317. type: "container",
  318. title: "制定资产转移申请",
  319. content: ""
  320. },
  321. {
  322. step: "2",
  323. type: "select",
  324. title: "主管科长审批",
  325. content: ""
  326. },
  327. {
  328. step: "3",
  329. type: "select",
  330. title: "分管副总经理审批",
  331. content: ""
  332. }
  333. ],
  334. // 设备维修
  335. deviceRepair: [
  336. {
  337. step: "1",
  338. type: "container",
  339. title: "制定维修计划",
  340. content: "设备设施保管员"
  341. },
  342. {
  343. step: "2",
  344. type: "select",
  345. title: "主管科长审核",
  346. content: ""
  347. },
  348. {
  349. step: "3",
  350. type: "select",
  351. title: "分管副总经理审核",
  352. content: ""
  353. },
  354. {
  355. step: "4",
  356. type: "container",
  357. title: "总经理审批",
  358. content: "总经理(张立)"
  359. },
  360. {
  361. step: "5",
  362. type: "select",
  363. title: "分公司审批",
  364. content: ""
  365. },
  366. {
  367. step: "6",
  368. type: "container",
  369. title: "维修计划执行",
  370. content: "设备设施保管员"
  371. }
  372. ],
  373. // 设备报废
  374. deviceScrap: [
  375. {
  376. step: "1",
  377. type: "container",
  378. title: "制定报废计划",
  379. content: "设备设施保管员"
  380. },
  381. {
  382. step: "2",
  383. type: "select",
  384. title: "主管科长审核",
  385. content: ""
  386. },
  387. {
  388. step: "3",
  389. type: "select",
  390. title: "分管副总经理审核",
  391. content: ""
  392. },
  393. {
  394. step: "4",
  395. type: "container",
  396. title: "总经理审批",
  397. content: "总经理(张立)"
  398. },
  399. {
  400. step: "5",
  401. type: "select",
  402. title: "分公司审批",
  403. content: ""
  404. },
  405. {
  406. step: "6",
  407. type: "container",
  408. title: "报废计划执行",
  409. content: "设备设施保管员"
  410. }
  411. ],
  412. // 设备维修改造
  413. deviceRepairReform: [
  414. {
  415. step: "1",
  416. type: "container",
  417. title: "制定维修计划",
  418. content: "设备设施保管员"
  419. },
  420. {
  421. step: "2",
  422. type: "select",
  423. title: "维修计划主管科长审核",
  424. content: ""
  425. },
  426. {
  427. step: "3",
  428. type: "select",
  429. title: " 维修计划分管副总经理审核",
  430. content: ""
  431. },
  432. {
  433. step: "4",
  434. type: "container",
  435. title: "维修计划总经理审批",
  436. content: "总经理(张立)"
  437. },
  438. {
  439. step: "5",
  440. type: "select",
  441. title: "维修计划分公司审批",
  442. content: ""
  443. },
  444. {
  445. step: "6",
  446. type: "container",
  447. title: "制定维修预算",
  448. content: "设备设施保管员"
  449. },
  450. {
  451. step: "7",
  452. type: "select",
  453. title: "维修预算主管科长审核",
  454. content: ""
  455. },
  456. {
  457. step: "8",
  458. type: "select",
  459. title: "维修预算分管副总经理审核",
  460. content: ""
  461. },
  462. {
  463. step: "9",
  464. type: "container",
  465. title: "维修预算总经理审批",
  466. content: "总经理(张立)"
  467. },
  468. {
  469. step: "10",
  470. type: "select",
  471. title: "维修预算分公司审批",
  472. content: ""
  473. },
  474. {
  475. step: "11",
  476. type: "container",
  477. title: "维修计划实施",
  478. content: "设备设施保管员"
  479. }
  480. ]
  481. }
  482. },
  483. methods: {
  484. //点击左侧树时
  485. handTreeClick(data) {
  486. this.dhierarchy = data.dhierarchy
  487. this.depotId = data.depotCode
  488. this.getRoleSelect()
  489. this.approverList()
  490. },
  491. filterNode(value, data) {
  492. if (!value) return true
  493. return data.label.indexOf(value) !== -1
  494. },
  495. gettotaltree() {
  496. let depotId = JSON.parse(getUser()).depotId
  497. findbyTreeData(depotId).then(res => {
  498. this.treeData = res.data
  499. if( res.data[0].dhierarchy == 1){
  500. this.depotId = res.data[0].children[0].depotCode
  501. this.$nextTick(() => {
  502. this.$refs.userManageTree.setCurrentKey( res.data[0].children[0].depotCode )
  503. this.approverList()
  504. })
  505. }else {
  506. this.depotId= JSON.parse(getUser()).depotId
  507. this.$nextTick(() => {
  508. this.$refs.userManageTree.setCurrentKey(JSON.parse(getUser()).depotId )
  509. this.approverList()
  510. })
  511. }
  512. })
  513. },
  514. //根据库id,角色查询用户下拉选
  515. getRoleSelect() {
  516. var params = {
  517. depotId: this.depotId,
  518. roleIds: this.rolesId
  519. }
  520. let resData = []
  521. roleList(params)
  522. .then(res => {
  523. if (res.code == 200) {
  524. resData = res.data
  525. this.tableData.forEach(item => {
  526. if (item.title.indexOf("主管科长") != -1) {
  527. this.$set(item, "approverSelect", res.data[33])
  528. } else if (
  529. item.title.indexOf("分管副总经理") != -1
  530. ) {
  531. this.$set(item, "approverSelect", res.data[35])
  532. } else if (item.title.indexOf("总经理") != -1) {
  533. this.$set(item, "approverSelect", res.data[34])
  534. }
  535. })
  536. }
  537. })
  538. .catch(err => {
  539. console.log(err)
  540. })
  541. if(this.type == 'xzjh' || this.type == 'yjcg' || this.type == 'sswxjh' || this.type == 'sswxys' || this.type == 'sbcg' ||this.type == 'sbwx'){
  542. let paramsNew = {
  543. depotId: 1,
  544. roleIds: 37
  545. }
  546. roleList(paramsNew)
  547. .then(res => {
  548. if (res.code == 200) {
  549. this.tableData.forEach(item => {
  550. if ( (this.type == 'xzjh' || this.type == 'yjcg') && item.title.indexOf("分公司主管处室") != -1 ) {
  551. this.$set(item, "approverSelect", res.data[37])
  552. }else if((this.type == 'sswxjh' || this.type == 'sswxys' || this.type == 'sbcg' ||this.type == 'sbwx') && item.title.indexOf("分公司") != -1){
  553. this.$set(item, "approverSelect", res.data[37])
  554. }
  555. })
  556. }
  557. })
  558. .catch(err => {
  559. console.log(err)
  560. })
  561. }else{
  562. this.tableData.forEach(item => {
  563. if ( item.title.indexOf("分公司主管处室") != -1 ) {
  564. this.$set(item, "approverSelect", resData[37])
  565. }
  566. })
  567. }
  568. },
  569. // 头部下拉选的值发生改变时
  570. headChange() {
  571. if (this.type == "tf") {
  572. this.tableData = this.meVentilation
  573. } else if (this.type == "xzjh") {
  574. // this.tableData = this.fumigation
  575. } else if (this.type == "xzsq") {
  576. // this.tableData = this.fumigation1
  577. } else if (this.type == "yjcg") {
  578. this.tableData = this.drugPurchase
  579. } else if (this.type == "yjly") {
  580. this.tableData = this.drugCollect
  581. } else if (this.type == "sbcg") {
  582. this.tableData = this.devicePurchase
  583. } else if (this.type == "sbly") {
  584. this.tableData = this.deviceCollect
  585. } else if(this.type == "sbgh"){
  586. this.tableData = this.deviceReturn
  587. }else if (this.type == "sbwx") {
  588. this.tableData = this.deviceRepair
  589. } else if (this.type == "sbbf") {
  590. // 设备报废
  591. this.tableData = this.deviceScrap
  592. } else if (this.type == "sbwxgz") {
  593. // 设备维修改造
  594. this.tableData = this.deviceRepairReform
  595. }
  596. this.approverList()
  597. },
  598. btnSave() {
  599. this.loading = true
  600. var flag = true
  601. for (let index = 0; index < this.tableData.length; index++) {
  602. const ele = this.tableData[index]
  603. if (ele.content == null) {
  604. flag = false
  605. this.$message("请先选择人员")
  606. this.loading = false
  607. return
  608. }
  609. }
  610. if (flag) this.submit()
  611. },
  612. //审批人管理提交
  613. submit() {
  614. this.loading = true
  615. var data = {
  616. data: this.tableData,
  617. // type: "tf",
  618. type: this.type,
  619. depot_id: this.depotId
  620. }
  621. approverSubmit(data)
  622. .then(res => {
  623. if (res.code == 200) {
  624. this.loading = false
  625. this.$message({
  626. message: "保存成功",
  627. type: "success"
  628. })
  629. console.log(res.data, "res.data")
  630. }
  631. })
  632. .catch(err => {
  633. this.loading = false
  634. console.log(err)
  635. })
  636. },
  637. //查看审批人列表
  638. approverList() {
  639. var type = this.type
  640. var userId = this.userInfo.uid
  641. var depotId = this.depotId
  642. checkList(type, userId, depotId)
  643. .then(res => {
  644. if (res.code == 200) {
  645. if (
  646. res.data == null ||
  647. res.data == "" ||
  648. res.data == undefined ||
  649. res.data == []
  650. ) {
  651. this.tableData = this.meVentilation
  652. } else {
  653. this.tableData = res.data
  654. }
  655. this.getRoleSelect()
  656. }
  657. })
  658. .catch(err => {
  659. console.log(err)
  660. })
  661. }
  662. },
  663. created() {
  664. this.gettotaltree()
  665. },
  666. mounted() {
  667. this.userInfo = JSON.parse(getUser())
  668. // this.depotId = this.userInfo.depotId
  669. // this.approverList()
  670. }
  671. }
  672. </script>
  673. <style lang="scss" scoped>
  674. .container {
  675. height: 100%;
  676. display: flex;
  677. #mainLeft {
  678. width: 340px;
  679. height: calc(100vh - 200px);
  680. border: 1px solid #e6e6e6;
  681. .el-tree-node__label {
  682. color: seagreen;
  683. }
  684. }
  685. #mainRight {
  686. margin-left: 20px;
  687. width: calc(100% - 340px);
  688. }
  689. }
  690. .table {
  691. width: 100%;
  692. text-align: center;
  693. margin: 20px 0 50px;
  694. }
  695. .btns {
  696. text-align: right;
  697. }
  698. </style>