detail.vue 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686
  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. const contracts = ["无合同", "有合同"];
  234. export default {
  235. data() {
  236. return {
  237. auth: false,
  238. status: ["售前", "转执行", "转运营", "转质保"],
  239. flowList: [],
  240. depRole: [],
  241. user: {},
  242. manager: "",
  243. contracts,
  244. formData: {
  245. manager: "",
  246. contract: null,
  247. },
  248. exeRules: {
  249. manager: {
  250. rules: [{ required: true, errorMessage: "请选择质保经理" }],
  251. },
  252. contract: {
  253. rules: [{ required: true, errorMessage: "请选择合同状态" }],
  254. },
  255. },
  256. wtyRules: {
  257. manager: {
  258. rules: [{ required: true, errorMessage: "请选择质保经理" }],
  259. },
  260. },
  261. optRules: {
  262. manager: {
  263. rules: [{ required: true, errorMessage: "请选择运营经理" }],
  264. },
  265. },
  266. };
  267. },
  268. computed: {
  269. ...mapState(["currentProject", "depUserTree"]),
  270. nodeList() {
  271. if (!this.flowList) return [];
  272. let flowInfo = this.flowList.find(
  273. (item) => item.id == this.currentProject.flow_id
  274. );
  275. if (!flowInfo) return [];
  276. let currentIndex = flowInfo.Nodes.findIndex(
  277. (item) => item.id == this.currentProject.node_id
  278. );
  279. return {
  280. currentIndex,
  281. list: flowInfo.Nodes.map((item) => ({
  282. title: item.node,
  283. desc: `审批人:${this.getAudits(item)}`,
  284. })),
  285. };
  286. },
  287. },
  288. onLoad(options) {
  289. this.auth = Boolean(options.auth);
  290. this.init();
  291. },
  292. methods: {
  293. async init() {
  294. this.user = uni.getStorageSync("user");
  295. console.log(this.user);
  296. let res;
  297. res = await queryFlow();
  298. this.flowList = res.data;
  299. res = await queryUserDetail(this.user);
  300. let depId = this.user.DepId;
  301. let dep = res.data.Dep.find((item) => item.ID == depId);
  302. this.depRole = dep.Role;
  303. },
  304. canAuth() {
  305. let { NodeInfo, audit_status, project_status } = this.currentProject;
  306. if (!NodeInfo || this.flowList.length == 0 || this.depRole.length == 0)
  307. return false;
  308. if (audit_status != 1) return false;
  309. if (project_status == 2)
  310. return this.currentProject.opt_manager_id == this.user.ID;
  311. if (project_status == 3)
  312. return this.currentProject.wty_manager_id == this.user.ID;
  313. let flow = this.flowList.find((item) => item.id == NodeInfo.flow_id);
  314. if (!flow) return false;
  315. let { NodeAudits } = flow.Nodes.find((item) => item.id == NodeInfo.id);
  316. const role = this.depRole.find((item) =>
  317. NodeAudits.find((audit) => audit.audit_role == item.ID)
  318. );
  319. return Boolean(role);
  320. },
  321. onHandleAudit(value) {
  322. if (value) {
  323. uni.showModal({
  324. title: "审批通过",
  325. content: "是否确认通过审批",
  326. confirmText: "通过",
  327. success: async (res) => {
  328. if (res.confirm) {
  329. let payload = {
  330. id: this.currentProject.id,
  331. project_full_code: this.currentProject.project_full_code,
  332. flow_id: this.currentProject.flow_id,
  333. node_id: this.currentProject.node_id,
  334. audit_status: 3,
  335. audit_comment: "",
  336. };
  337. await authApproval(payload);
  338. uni.showToast({
  339. title: "审核成功",
  340. });
  341. setTimeout(function () {
  342. uni.hideToast();
  343. uni.navigateBack();
  344. }, 1800);
  345. }
  346. },
  347. });
  348. } else {
  349. uni.showModal({
  350. title: "是否确认拒绝",
  351. content: "拒绝理由",
  352. editable: true,
  353. success: async (res) => {
  354. if (res.confirm) {
  355. let payload = {
  356. id: this.currentProject.id,
  357. project_full_code: this.currentProject.project_full_code,
  358. flow_id: this.currentProject.flow_id,
  359. node_id: this.currentProject.node_id,
  360. audit_status: 2,
  361. audit_comment: res.content,
  362. };
  363. await authApproval(payload);
  364. uni.showToast({
  365. title: "已拒绝",
  366. });
  367. setTimeout(function () {
  368. uni.hideToast();
  369. uni.navigateBack();
  370. }, 1800);
  371. }
  372. },
  373. });
  374. }
  375. },
  376. getAudits(nodeInfo) {
  377. switch (nodeInfo.id) {
  378. case 11:
  379. return "执行项目经理";
  380. case 12:
  381. return "运营经理";
  382. case 13:
  383. return "执行项目经理";
  384. case 14:
  385. return "质保经理";
  386. default:
  387. return (nodeInfo.NodeAudits || [])
  388. .map((item) => item.AuthorRoleInfo.Name)
  389. .join(",");
  390. }
  391. },
  392. canEdit(index) {
  393. let {
  394. audit_status,
  395. project_status,
  396. author,
  397. LeaderId,
  398. opt_manager_id,
  399. wty_manager_id,
  400. } = this.currentProject;
  401. //audit_status: 0未提审1审核中2审核拒绝3审核通过
  402. //project_status: 0售前1执行2转运营3转质保
  403. switch (index) {
  404. //编辑删除提审
  405. case 0:
  406. //售前阶段,未提审/审核被拒,创建人/管理员
  407. return (
  408. project_status == 0 &&
  409. (audit_status == 0 || audit_status == 2) &&
  410. (this.user.ID == author || this.user.IsSuper)
  411. );
  412. //成员管理
  413. case 1:
  414. //售前/执行/运营/质保,审核通过,项目经理/管理员
  415. let manager;
  416. switch (project_status) {
  417. case 0:
  418. manager = (this.user.ID == author);
  419. break;
  420. case 1:
  421. manager = (this.user.ID == LeaderId);
  422. break;
  423. case 2:
  424. manager = (this.user.ID == LeaderId || this.user.ID == opt_manager_id);
  425. break;
  426. case 3:
  427. manager = (this.user.ID == LeaderId || this.user.ID == wty_manager_id);
  428. break;
  429. }
  430. return (
  431. audit_status == 3 && (manager || this.user.IsSuper)
  432. );
  433. //转执行
  434. case 2:
  435. //售前,审核通过,售前经理/管理员
  436. return (
  437. project_status == 0 &&
  438. audit_status == 3 &&
  439. (this.user.ID == author || this.user.IsSuper)
  440. );
  441. //转质保运营
  442. case 3:
  443. //执行,审核通过,执行经理/管理员
  444. return (
  445. project_status == 1 &&
  446. audit_status == 3 &&
  447. (this.user.ID == LeaderId || this.user.IsSuper)
  448. );
  449. }
  450. },
  451. onEdit() {
  452. uni.navigateTo({
  453. url: `./add?project_id=${this.currentProject.id}`,
  454. });
  455. },
  456. onDelete() {
  457. uni.showModal({
  458. title: "删除项目",
  459. content: "是否确认删除该项目",
  460. confirmText: "删除",
  461. confirmColor: "#ff7875",
  462. success: async (res) => {
  463. if (res.confirm) {
  464. await deleteApproval(this.currentProject);
  465. uni.showToast({
  466. title: "删除成功",
  467. });
  468. setTimeout(function () {
  469. uni.hideToast();
  470. uni.navigateBack();
  471. }, 1800);
  472. }
  473. },
  474. });
  475. },
  476. onSubmitAuth() {
  477. uni.showModal({
  478. title: "提交审核",
  479. content: "是否确认提交审核",
  480. confirmText: "提审",
  481. success: async (res) => {
  482. if (res.confirm) {
  483. let payload = {
  484. id: this.currentProject.id,
  485. flow_id: this.currentProject.flow_id,
  486. node_id: this.currentProject.node_id,
  487. };
  488. await submitAudit(payload);
  489. uni.showToast({
  490. title: "提审成功",
  491. });
  492. setTimeout(function () {
  493. uni.hideToast();
  494. uni.navigateBack();
  495. }, 1800);
  496. }
  497. },
  498. });
  499. },
  500. onMember() {
  501. uni.navigateTo({
  502. url: "./member",
  503. });
  504. },
  505. changeManager(e) {
  506. if (e.detail.value.length > 0)
  507. this.formData.manager = e.detail.value[e.detail.value.length - 1].value;
  508. else this.formData.manager = "";
  509. },
  510. onExecute() {
  511. this.$refs.exePopup.open();
  512. },
  513. changeContract(e) {
  514. this.formData.contract = e.detail.value;
  515. },
  516. async submitExecute() {
  517. this.$refs.exe.validate(async (err) => {
  518. if (!err) {
  519. const [dep_id, manager_id] = this.formData.manager.split("-");
  520. let payload = {
  521. project_code_id: this.currentProject.id,
  522. with_contract: Number(this.formData.contract),
  523. dep_id: Number(dep_id),
  524. exe_manager_id: Number(manager_id),
  525. };
  526. await startExecution(payload);
  527. this.$refs.exePopup.close();
  528. uni.showToast({
  529. title: "转执行送审成功",
  530. });
  531. setTimeout(function () {
  532. uni.hideToast();
  533. uni.navigateBack();
  534. }, 1800);
  535. }
  536. });
  537. },
  538. onWarranty() {
  539. this.$refs.wtyPopup.open();
  540. },
  541. async submitWarranty() {
  542. this.$refs.wty.validate(async (err) => {
  543. if (!err) {
  544. const [dep_id, manager_id] = this.formData.manager.split("-");
  545. let payload = {
  546. project_code_id: this.currentProject.id,
  547. dep_id: Number(dep_id),
  548. wty_manager_id: Number(manager_id),
  549. };
  550. await startWarranty(payload);
  551. this.$refs.wtyPopup.close();
  552. uni.showToast({
  553. title: "转质保送审成功",
  554. });
  555. setTimeout(function () {
  556. uni.hideToast();
  557. uni.navigateBack();
  558. }, 1800);
  559. }
  560. });
  561. },
  562. onOperate() {
  563. this.$refs.optPopup.open();
  564. },
  565. async submitOperate() {
  566. this.$refs.opt.validate(async (err) => {
  567. if (!err) {
  568. const [dep_id, manager_id] = this.formData.manager.split("-");
  569. let payload = {
  570. project_code_id: this.currentProject.id,
  571. dep_id: Number(dep_id),
  572. opt_manager_id: Number(manager_id),
  573. };
  574. await startOperate(payload);
  575. this.$refs.optPopup.close();
  576. uni.showToast({
  577. title: "转运营送审成功",
  578. });
  579. setTimeout(function () {
  580. uni.hideToast();
  581. uni.navigateBack();
  582. }, 1800);
  583. }
  584. });
  585. },
  586. onCancel() {
  587. this.$refs.exePopup.close();
  588. this.$refs.wtyPopup.close();
  589. this.$refs.optPopup.close();
  590. this.formData = {
  591. manager: "",
  592. contract: null,
  593. };
  594. },
  595. },
  596. };
  597. </script>
  598. <style lang="less" scoped>
  599. .content {
  600. display: flex;
  601. flex-wrap: wrap;
  602. }
  603. .main {
  604. width: 100%;
  605. padding-bottom: 60px;
  606. }
  607. .title {
  608. width: 100%;
  609. padding: 0 20px 20px 20px;
  610. font: 24px bold;
  611. }
  612. .list {
  613. margin: 0 10% 20px 10%;
  614. }
  615. .detail {
  616. width: 100%;
  617. padding: 15px 0;
  618. font-size: 18px;
  619. display: flex;
  620. justify-items: space-between;
  621. .subTitle {
  622. width: 40%;
  623. }
  624. .detailContent {
  625. width: 60%;
  626. }
  627. }
  628. .select {
  629. width: 100%;
  630. height: 72rpx;
  631. line-height: 70rpx;
  632. border: 1px solid #666;
  633. padding-left: 20rpx;
  634. }
  635. ::v-deep {
  636. .uni-steps__column-title {
  637. font-size: 18px;
  638. line-height: 24px;
  639. }
  640. .uni-steps__column-desc {
  641. font-size: 14px;
  642. line-height: 18px;
  643. }
  644. }
  645. .editBtns {
  646. display: flex;
  647. justify-content: space-around;
  648. flex-wrap: wrap;
  649. margin: 0 5%;
  650. .edit {
  651. width: 30%;
  652. margin-bottom: 20px;
  653. font-size: 16px;
  654. text-align: center;
  655. }
  656. }
  657. .group {
  658. width: 100%;
  659. display: flex;
  660. position: fixed;
  661. flex-wrap: wrap;
  662. justify-content: flex-start;
  663. bottom: 0;
  664. left: 0;
  665. .commit {
  666. width: 50%;
  667. border-radius: 0;
  668. margin: inherit;
  669. }
  670. }
  671. .depSelect {
  672. width: 200px;
  673. }
  674. </style>