detail.vue 19 KB

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