detail.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637
  1. <template>
  2. <view class="content">
  3. <view class="title"> 项目详情 </view>
  4. <view class="main">
  5. <view class="list">
  6. <view class="detail">
  7. <span class="subTitle">项目名称:</span>
  8. <span class="detailContent">{{ currentProject.project_name }}</span>
  9. </view>
  10. <view class="detail" v-if="currentProject.TypeInfo">
  11. <span class="subTitle">项目类别:</span>
  12. <span class="detailContent">{{ currentProject.TypeInfo.name }}</span>
  13. </view>
  14. <view class="detail" v-if="currentProject.IndustryInfo">
  15. <span class="subTitle">行业名称:</span>
  16. <span class="detailContent">
  17. {{ currentProject.IndustryInfo.name }}
  18. </span>
  19. </view>
  20. <view class="detail">
  21. <span class="subTitle">流程:</span>
  22. <span class="detailContent">{{ currentProject.FlowInfo.name }}</span>
  23. </view>
  24. <view class="detail">
  25. <span class="subTitle">状态:</span>
  26. <span class="detailContent">
  27. {{ status[currentProject.project_status] }}
  28. </span>
  29. </view>
  30. <view class="detail">
  31. <span class="subTitle">节点:</span>
  32. <span class="detailContent">
  33. {{ `${currentProject.NodeInfo.node}(` }}
  34. <span v-if="currentProject.audit_status == 0">待提交</span>
  35. <span
  36. v-if="currentProject.audit_status == 1"
  37. :style="{ color: '#1890ff' }"
  38. >
  39. 审核中
  40. </span>
  41. <span
  42. v-if="currentProject.audit_status == 2"
  43. :style="{ color: '#f5222d' }"
  44. >
  45. 审核拒绝
  46. </span>
  47. <span
  48. v-if="currentProject.audit_status == 3"
  49. :style="{ color: '#a0d911' }"
  50. >
  51. 审核通过
  52. </span>
  53. <span>)</span>
  54. </span>
  55. </view>
  56. <view class="detail" v-if="currentProject.audit_status == 2">
  57. <span class="subTitle">拒绝原因:</span>
  58. <span class="detailContent">
  59. {{ currentProject.audit_comment }}
  60. </span>
  61. </view>
  62. <view class="detail" v-if="currentProject.location">
  63. <span class="subTitle">项目地区:</span>
  64. <span class="detailContent">
  65. {{ `${currentProject.location}(${currentProject.location_code})` }}
  66. </span>
  67. </view>
  68. <view class="detail" v-if="currentProject.name">
  69. <span class="subTitle">项目简称:</span>
  70. <span class="detailContent">{{ currentProject.name }}</span>
  71. </view>
  72. <view class="detail" v-if="currentProject.version">
  73. <span class="subTitle">项目批次:</span>
  74. <span class="detailContent">{{ currentProject.version }}期</span>
  75. </view>
  76. <view class="detail" v-if="currentProject.AuthorUser">
  77. <span class="subTitle">创建人:</span>
  78. <span class="detailContent">{{
  79. currentProject.AuthorUser.CName
  80. }}</span>
  81. </view>
  82. <view class="detail" v-if="currentProject.AuthorDepInfo">
  83. <span class="subTitle">所属部门:</span>
  84. <span class="detailContent">
  85. {{ currentProject.AuthorDepInfo.Name }}
  86. </span>
  87. </view>
  88. <view class="detail">
  89. <span class="subTitle">项目编号:</span>
  90. <span class="detailContent">
  91. {{ currentProject.project_full_code }}
  92. </span>
  93. </view>
  94. </view>
  95. <view class="title">审核详情 </view>
  96. <view class="list">
  97. <uni-steps
  98. :options="nodeList.list"
  99. :active="nodeList.currentIndex"
  100. direction="column"
  101. />
  102. </view>
  103. <uni-card title="操作" v-if="!this.auth">
  104. <view class="editBtns" slot="actions">
  105. <view class="edit" v-if="canEdit(0)" @click="onEdit()">编辑</view>
  106. <view class="edit" v-if="canEdit(0)" @click="onDelete()">删除</view>
  107. <view class="edit" v-if="canEdit(0)" @click="onSubmitAuth()">
  108. 提交审核
  109. </view>
  110. <view class="edit" v-if="canEdit(1)" @click="onMember()"
  111. >成员管理
  112. </view>
  113. <view class="edit" v-if="canEdit(2)" @click="onExecute()">
  114. 转执行
  115. </view>
  116. <view class="edit" v-if="canEdit(3)" @click="onWarranty()">
  117. 转质保
  118. </view>
  119. <view class="edit" v-if="canEdit(3)" @click="onOperate()">
  120. 转运营
  121. </view>
  122. </view>
  123. </uni-card>
  124. </view>
  125. <view class="group" v-if="this.auth && canAuth()">
  126. <button @click="onHandleAudit(0)" class="commit">审核拒绝</button>
  127. <button @click="onHandleAudit(1)" type="primary" class="commit">
  128. 审核通过
  129. </button>
  130. </view>
  131. <uni-popup ref="exePopup" type="dialog">
  132. <uni-popup-dialog title="转执行" type="info" before-close>
  133. <uni-forms
  134. ref="exe"
  135. :modelValue="formData"
  136. label-position="left"
  137. :rules="exeRules"
  138. >
  139. <uni-forms-item required label="执行经理:" name="manager">
  140. <uni-data-picker
  141. class="depSelect"
  142. placeholder="请选择执行经理"
  143. :localdata="depUserTree"
  144. @change="changeManager"
  145. />
  146. </uni-forms-item>
  147. </uni-forms>
  148. </uni-popup-dialog>
  149. </uni-popup>
  150. <uni-popup ref="wtyPopup" type="dialog">
  151. <uni-popup-dialog
  152. title="转质保"
  153. type="info"
  154. @confirm="submitWarranty"
  155. @close="onCancel"
  156. before-close
  157. >
  158. <uni-forms
  159. ref="wty"
  160. :modelValue="formData"
  161. label-position="left"
  162. :rules="wtyRules"
  163. >
  164. <uni-forms-item required label="质保经理:" name="manager">
  165. <uni-data-picker
  166. class="depSelect"
  167. placeholder="请选择质保经理"
  168. :localdata="depUserTree"
  169. @change="changeManager"
  170. />
  171. </uni-forms-item>
  172. </uni-forms>
  173. </uni-popup-dialog>
  174. </uni-popup>
  175. <uni-popup ref="optPopup" type="dialog">
  176. <uni-popup-dialog
  177. title="转运营"
  178. type="info"
  179. @confirm="submitOperate"
  180. @close="onCancel"
  181. before-close
  182. >
  183. <uni-forms
  184. ref="opt"
  185. :modelValue="formData"
  186. label-position="left"
  187. :rules="optRules"
  188. >
  189. <uni-forms-item required label="运营经理:" name="manager">
  190. <uni-data-picker
  191. class="depSelect"
  192. placeholder="请选择运营经理"
  193. :localdata="depUserTree"
  194. @change="changeManager"
  195. />
  196. </uni-forms-item>
  197. </uni-forms>
  198. </uni-popup-dialog>
  199. </uni-popup>
  200. </view>
  201. </template>
  202. <script>
  203. import { mapState } from "vuex";
  204. import {
  205. queryFlow,
  206. deleteApproval,
  207. submitAudit,
  208. queryUserDetail,
  209. authApproval,
  210. startExecution,
  211. startWarranty,
  212. startOperate,
  213. } from "@/services/project";
  214. export default {
  215. data() {
  216. return {
  217. auth: false,
  218. status: ["售前", "转执行", "转运营", "转质保"],
  219. flowList: [],
  220. depRole: [],
  221. user: {},
  222. manager: "",
  223. formData: {
  224. manager: "",
  225. contract: 0,
  226. },
  227. exeRules: {
  228. manager: {
  229. rules: [{ required: true, errorMessage: "请选择质保经理" }],
  230. },
  231. },
  232. wtyRules: {
  233. manager: {
  234. rules: [{ required: true, errorMessage: "请选择质保经理" }],
  235. },
  236. },
  237. optRules: {
  238. manager: {
  239. rules: [{ required: true, errorMessage: "请选择运营经理" }],
  240. },
  241. },
  242. };
  243. },
  244. computed: {
  245. ...mapState(["currentProject", "depUserTree"]),
  246. nodeList() {
  247. if (!this.flowList) return [];
  248. let flowInfo = this.flowList.find(
  249. (item) => item.id == this.currentProject.flow_id
  250. );
  251. if (!flowInfo) return [];
  252. let currentIndex = flowInfo.Nodes.findIndex(
  253. (item) => item.id == this.currentProject.node_id
  254. );
  255. return {
  256. currentIndex,
  257. list: flowInfo.Nodes.map((item) => ({
  258. title: item.node,
  259. desc: `审批人:${this.getAudits(item)}`,
  260. })),
  261. };
  262. },
  263. },
  264. onLoad(options) {
  265. this.auth = Boolean(options.auth);
  266. this.init();
  267. },
  268. methods: {
  269. async init() {
  270. this.user = uni.getStorageSync("user");
  271. let res;
  272. res = await queryFlow();
  273. this.flowList = res.data;
  274. res = await queryUserDetail(this.user);
  275. let depId = this.user.DepId;
  276. let dep = res.data.Dep.find((item) => item.ID == depId);
  277. this.depRole = dep.Role;
  278. },
  279. canAuth() {
  280. let { NodeInfo, audit_status, project_status } = this.currentProject;
  281. if (!NodeInfo || this.flowList.length == 0 || this.depRole.length == 0)
  282. return false;
  283. if (audit_status != 1) return false;
  284. if (project_status == 2)
  285. return this.currentProject.opt_manager_id == this.user.ID;
  286. if (project_status == 3)
  287. return this.currentProject.wty_manager_id == this.user.ID;
  288. let flow = this.flowList.find((item) => item.id == NodeInfo.flow_id);
  289. if (!flow) return false;
  290. let { NodeAudits } = flow.Nodes.find((item) => item.id == NodeInfo.id);
  291. const role = this.depRole.find((item) =>
  292. NodeAudits.find((audit) => audit.audit_role == item.ID)
  293. );
  294. return Boolean(role);
  295. },
  296. onHandleAudit(value) {
  297. if (value) {
  298. uni.showModal({
  299. title: "审批通过",
  300. content: "是否确认通过审批",
  301. confirmText: "通过",
  302. success: async (res) => {
  303. if (res.confirm) {
  304. let payload = {
  305. id: this.currentProject.id,
  306. project_full_code: this.currentProject.project_full_code,
  307. flow_id: this.currentProject.flow_id,
  308. node_id: this.currentProject.node_id,
  309. audit_status: 3,
  310. audit_comment: "",
  311. };
  312. await authApproval(payload);
  313. uni.showToast({
  314. title: "审核成功",
  315. });
  316. setTimeout(function () {
  317. uni.hideToast();
  318. uni.navigateTo({
  319. url: "./auth",
  320. });
  321. }, 1800);
  322. }
  323. },
  324. });
  325. } else {
  326. uni.showModal({
  327. title: "是否确认拒绝",
  328. content: "拒绝理由",
  329. editable: true,
  330. success: async (res) => {
  331. if (res.confirm) {
  332. let payload = {
  333. id: this.currentProject.id,
  334. project_full_code: this.currentProject.project_full_code,
  335. flow_id: this.currentProject.flow_id,
  336. node_id: this.currentProject.node_id,
  337. audit_status: 2,
  338. audit_comment: res.content,
  339. };
  340. await authApproval(payload);
  341. uni.showToast({
  342. title: "已拒绝",
  343. });
  344. setTimeout(function () {
  345. uni.hideToast();
  346. uni.navigateTo({
  347. url: "./auth",
  348. });
  349. }, 1800);
  350. }
  351. },
  352. });
  353. }
  354. },
  355. getAudits(nodeInfo) {
  356. switch (nodeInfo.id) {
  357. case 11:
  358. return "执行项目经理";
  359. case 12:
  360. return "运营经理";
  361. case 13:
  362. return "执行项目经理";
  363. case 14:
  364. return "质保经理";
  365. default:
  366. return (nodeInfo.NodeAudits || [])
  367. .map((item) => item.AuthorRoleInfo.Name)
  368. .join(",");
  369. }
  370. },
  371. canEdit(index) {
  372. let {
  373. audit_status,
  374. project_status,
  375. author,
  376. LeaderId,
  377. opt_manager_id,
  378. wty_manager_id,
  379. } = this.currentProject;
  380. //audit_status: 0未提审1审核中2审核拒绝3审核通过
  381. //project_status: 0售前1执行2转运营3转质保
  382. switch (index) {
  383. //编辑删除提审
  384. case 0:
  385. //售前阶段,未提审/审核被拒,创建人/管理员
  386. return (
  387. project_status == 0 &&
  388. (audit_status == 0 || audit_status == 2) &&
  389. (this.user.ID == author || this.user.IsSuper)
  390. );
  391. //成员管理
  392. case 1:
  393. //售前/执行/运营/质保,审核通过,项目经理/管理员
  394. let manager;
  395. switch (project_status) {
  396. case 0:
  397. manager = author;
  398. break;
  399. case 1:
  400. manager = LeaderId;
  401. break;
  402. case 2:
  403. manager = opt_manager_id;
  404. break;
  405. case 3:
  406. manager = wty_manager_id;
  407. break;
  408. }
  409. return (
  410. audit_status == 3 && (this.user.ID == manager || this.user.IsSuper)
  411. );
  412. //转执行
  413. case 2:
  414. //售前,审核通过,售前经理/管理员
  415. return (
  416. project_status == 0 &&
  417. audit_status == 3 &&
  418. (this.user.ID == author || this.user.IsSuper)
  419. );
  420. //转质保运营
  421. case 3:
  422. //执行,审核通过,执行经理/管理员
  423. return (
  424. project_status == 1 &&
  425. audit_status == 3 &&
  426. (this.user.ID == LeaderId || this.user.IsSuper)
  427. );
  428. }
  429. },
  430. onEdit() {
  431. uni.navigateTo({
  432. url: `./add?project_id=${this.currentProject.id}`,
  433. });
  434. },
  435. onDelete() {
  436. uni.showModal({
  437. title: "删除项目",
  438. content: "是否确认删除该项目",
  439. confirmText: "删除",
  440. confirmColor: "#ff7875",
  441. success: async (res) => {
  442. if (res.confirm) {
  443. await deleteApproval(this.currentProject);
  444. uni.showToast({
  445. title: "删除成功",
  446. });
  447. setTimeout(function () {
  448. uni.hideToast();
  449. uni.navigateTo({
  450. url: "./list",
  451. });
  452. }, 1800);
  453. }
  454. },
  455. });
  456. },
  457. onSubmitAuth() {
  458. uni.showModal({
  459. title: "提交审核",
  460. content: "是否确认提交审核",
  461. confirmText: "提审",
  462. success: async (res) => {
  463. if (res.confirm) {
  464. let payload = {
  465. id: this.currentProject.id,
  466. flow_id: this.currentProject.flow_id,
  467. node_id: this.currentProject.node_id,
  468. };
  469. await submitAudit(payload);
  470. uni.showToast({
  471. title: "提审成功",
  472. });
  473. setTimeout(function () {
  474. uni.hideToast();
  475. uni.navigateTo({
  476. url: "./list",
  477. });
  478. }, 1800);
  479. }
  480. },
  481. });
  482. },
  483. onMember() {
  484. uni.navigateTo({
  485. url: "./member",
  486. });
  487. },
  488. changeManager(e) {
  489. if (e.detail.value.length > 0)
  490. this.formData.manager = e.detail.value[e.detail.value.length - 1].value;
  491. else this.formData.manager = "";
  492. },
  493. onExecute() {
  494. this.$refs.exePopup.open();
  495. },
  496. onWarranty() {
  497. this.$refs.wtyPopup.open();
  498. },
  499. async submitWarranty() {
  500. this.$refs.wty.validate(async (err) => {
  501. if (!err) {
  502. const [dep_id, manager_id] = this.formData.manager.split("-");
  503. let payload = {
  504. project_code_id: this.currentProject.id,
  505. dep_id: Number(dep_id),
  506. wty_manager_id: Number(manager_id),
  507. };
  508. await startWarranty(payload);
  509. this.$refs.wtyPopup.close();
  510. uni.showToast({
  511. title: "转质保送审成功",
  512. });
  513. setTimeout(function () {
  514. uni.hideToast();
  515. uni.navigateTo({
  516. url: "./list",
  517. });
  518. }, 1800);
  519. }
  520. });
  521. },
  522. onOperate() {
  523. this.$refs.optPopup.open();
  524. },
  525. async submitOperate() {
  526. this.$refs.opt.validate(async (err) => {
  527. if (!err) {
  528. const [dep_id, manager_id] = this.formData.manager.split("-");
  529. let payload = {
  530. project_code_id: this.currentProject.id,
  531. dep_id: Number(dep_id),
  532. opt_manager_id: Number(manager_id),
  533. };
  534. await startOperate(payload);
  535. this.$refs.optPopup.close();
  536. uni.showToast({
  537. title: "转运营送审成功",
  538. });
  539. setTimeout(function () {
  540. uni.hideToast();
  541. uni.navigateTo({
  542. url: "./list",
  543. });
  544. }, 1800);
  545. }
  546. });
  547. },
  548. onCancel() {
  549. this.$refs.exePopup.close();
  550. this.$refs.wtyPopup.close();
  551. this.$refs.optPopup.close();
  552. },
  553. },
  554. };
  555. </script>
  556. <style lang="less" scoped>
  557. .content {
  558. display: flex;
  559. flex-wrap: wrap;
  560. }
  561. .main {
  562. width: 100%;
  563. padding-bottom: 60px;
  564. }
  565. .title {
  566. width: 100%;
  567. padding: 0 20px 20px 20px;
  568. font: 24px bold;
  569. }
  570. .list {
  571. margin: 0 10% 20px 10%;
  572. }
  573. .detail {
  574. width: 100%;
  575. padding: 15px 0;
  576. font-size: 18px;
  577. display: flex;
  578. justify-items: space-between;
  579. .subTitle {
  580. width: 30%;
  581. }
  582. .detailContent {
  583. width: 70%;
  584. }
  585. }
  586. ::v-deep {
  587. .uni-steps__column-title {
  588. font-size: 18px;
  589. line-height: 24px;
  590. }
  591. .uni-steps__column-desc {
  592. font-size: 14px;
  593. line-height: 18px;
  594. }
  595. }
  596. .editBtns {
  597. display: flex;
  598. justify-content: space-around;
  599. flex-wrap: wrap;
  600. margin: 0 5%;
  601. .edit {
  602. width: 30%;
  603. margin-bottom: 20px;
  604. font-size: 16px;
  605. text-align: center;
  606. }
  607. }
  608. .group {
  609. width: 100%;
  610. display: flex;
  611. position: fixed;
  612. flex-wrap: wrap;
  613. justify-content: flex-start;
  614. bottom: 0;
  615. left: 0;
  616. .commit {
  617. width: 50%;
  618. border-radius: 0;
  619. margin: inherit;
  620. }
  621. }
  622. .depSelect {
  623. width: 200px;
  624. }
  625. </style>