detail.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626
  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">
  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 title="转质保" type="info" @confirm="submitWarranty">
  152. <uni-forms
  153. ref="wty"
  154. :modelValue="formData"
  155. label-position="left"
  156. :rules="wtyRules"
  157. >
  158. <uni-forms-item required label="质保经理:" name="manager">
  159. <uni-data-picker
  160. class="depSelect"
  161. placeholder="请选择质保经理"
  162. :localdata="depUserTree"
  163. @change="changeManager"
  164. />
  165. </uni-forms-item>
  166. </uni-forms>
  167. </uni-popup-dialog>
  168. </uni-popup>
  169. <uni-popup ref="optPopup" type="dialog">
  170. <uni-popup-dialog title="转运营" type="info" @confirm="submitOperate">
  171. <uni-forms
  172. ref="opt"
  173. :modelValue="formData"
  174. label-position="left"
  175. :rules="optRules"
  176. >
  177. <uni-forms-item required label="运营经理:" name="manager">
  178. <uni-data-picker
  179. class="depSelect"
  180. placeholder="请选择运营经理"
  181. :localdata="depUserTree"
  182. @change="changeManager"
  183. />
  184. </uni-forms-item>
  185. </uni-forms>
  186. </uni-popup-dialog>
  187. </uni-popup>
  188. </view>
  189. </template>
  190. <script>
  191. import { mapState } from "vuex";
  192. import {
  193. queryFlow,
  194. deleteApproval,
  195. submitAudit,
  196. queryUserDetail,
  197. authApproval,
  198. startExecution,
  199. startWarranty,
  200. startOperate,
  201. } from "@/services/project";
  202. import uniFormsItem from "../../uni_modules/uni-forms/components/uni-forms-item/uni-forms-item.vue";
  203. export default {
  204. components: { uniFormsItem },
  205. data() {
  206. return {
  207. auth: false,
  208. status: ["售前", "转执行", "转运营", "转质保"],
  209. flowList: [],
  210. depRole: [],
  211. user: {},
  212. manager: "",
  213. formData: {
  214. manager: "",
  215. contract: 0,
  216. },
  217. exeRules: {
  218. manager: {
  219. rules: [{ required: true, errorMessage: "请选择质保经理" }],
  220. },
  221. },
  222. wtyRules: {
  223. manager: {
  224. rules: [{ required: true, errorMessage: "请选择质保经理" }],
  225. },
  226. },
  227. optRules: {
  228. manager: {
  229. rules: [{ required: true, errorMessage: "请选择运营经理" }],
  230. },
  231. },
  232. };
  233. },
  234. computed: {
  235. ...mapState(["currentProject", "depUserTree"]),
  236. nodeList() {
  237. if (!this.flowList) return [];
  238. let flowInfo = this.flowList.find(
  239. (item) => item.id == this.currentProject.flow_id
  240. );
  241. if (!flowInfo) return [];
  242. let currentIndex = flowInfo.Nodes.findIndex(
  243. (item) => item.id == this.currentProject.node_id
  244. );
  245. return {
  246. currentIndex,
  247. list: flowInfo.Nodes.map((item) => ({
  248. title: item.node,
  249. desc: `审批人:${this.getAudits(item)}`,
  250. })),
  251. };
  252. },
  253. },
  254. onLoad(options) {
  255. this.auth = Boolean(options.auth);
  256. this.init();
  257. },
  258. methods: {
  259. async init() {
  260. this.user = uni.getStorageSync("user");
  261. let res;
  262. res = await queryFlow();
  263. this.flowList = res.data;
  264. res = await queryUserDetail(this.user);
  265. let depId = this.user.DepId;
  266. let dep = res.data.Dep.find((item) => item.ID == depId);
  267. this.depRole = dep.Role;
  268. },
  269. canAuth() {
  270. let { NodeInfo, audit_status, project_status } = this.currentProject;
  271. if (!NodeInfo || this.flowList.length == 0 || this.depRole.length == 0)
  272. return false;
  273. if (audit_status != 1) return false;
  274. if (project_status == 2)
  275. return this.currentProject.opt_manager_id == this.user.ID;
  276. if (project_status == 3)
  277. return this.currentProject.wty_manager_id == this.user.ID;
  278. let flow = this.flowList.find((item) => item.id == NodeInfo.flow_id);
  279. if (!flow) return false;
  280. let { NodeAudits } = flow.Nodes.find((item) => item.id == NodeInfo.id);
  281. const role = this.depRole.find((item) =>
  282. NodeAudits.find((audit) => audit.audit_role == item.ID)
  283. );
  284. return Boolean(role);
  285. },
  286. onHandleAudit(value) {
  287. if (value) {
  288. uni.showModal({
  289. title: "审批通过",
  290. content: "是否确认通过审批",
  291. confirmText: "通过",
  292. success: async (res) => {
  293. if (res.confirm) {
  294. let payload = {
  295. id: this.currentProject.id,
  296. project_full_code: this.currentProject.project_full_code,
  297. flow_id: this.currentProject.flow_id,
  298. node_id: this.currentProject.node_id,
  299. audit_status: 3,
  300. audit_comment: "",
  301. };
  302. await authApproval(payload);
  303. uni.showToast({
  304. title: "审核成功",
  305. });
  306. setTimeout(function () {
  307. uni.hideToast();
  308. uni.navigateTo({
  309. url: "./auth",
  310. });
  311. }, 1800);
  312. }
  313. },
  314. });
  315. } else {
  316. uni.showModal({
  317. title: "是否确认拒绝",
  318. content: "拒绝理由",
  319. editable: true,
  320. success: async (res) => {
  321. if (res.confirm) {
  322. let payload = {
  323. id: this.currentProject.id,
  324. project_full_code: this.currentProject.project_full_code,
  325. flow_id: this.currentProject.flow_id,
  326. node_id: this.currentProject.node_id,
  327. audit_status: 2,
  328. audit_comment: res.content,
  329. };
  330. await authApproval(payload);
  331. uni.showToast({
  332. title: "已拒绝",
  333. });
  334. setTimeout(function () {
  335. uni.hideToast();
  336. uni.navigateTo({
  337. url: "./auth",
  338. });
  339. }, 1800);
  340. }
  341. },
  342. });
  343. }
  344. },
  345. getAudits(nodeInfo) {
  346. switch (nodeInfo.id) {
  347. case 11:
  348. return "执行项目经理";
  349. case 12:
  350. return "运营经理";
  351. case 13:
  352. return "执行项目经理";
  353. case 14:
  354. return "质保经理";
  355. default:
  356. return (nodeInfo.NodeAudits || [])
  357. .map((item) => item.AuthorRoleInfo.Name)
  358. .join(",");
  359. }
  360. },
  361. canEdit(index) {
  362. let {
  363. audit_status,
  364. project_status,
  365. author,
  366. LeaderId,
  367. opt_manager_id,
  368. wty_manager_id,
  369. } = this.currentProject;
  370. //audit_status: 0未提审1审核中2审核拒绝3审核通过
  371. //project_status: 0售前1执行2转运营3转质保
  372. switch (index) {
  373. //编辑删除提审
  374. case 0:
  375. //售前阶段,未提审/审核被拒,创建人/管理员
  376. return (
  377. project_status == 0 &&
  378. (audit_status == 0 || audit_status == 2) &&
  379. (this.user.ID == author || this.user.IsSuper)
  380. );
  381. //成员管理
  382. case 1:
  383. //售前/执行/运营/质保,审核通过,项目经理/管理员
  384. let manager;
  385. switch (project_status) {
  386. case 0:
  387. manager = author;
  388. break;
  389. case 1:
  390. manager = LeaderId;
  391. break;
  392. case 2:
  393. manager = opt_manager_id;
  394. break;
  395. case 3:
  396. manager = wty_manager_id;
  397. break;
  398. }
  399. return (
  400. audit_status == 3 && (this.user.ID == manager || this.user.IsSuper)
  401. );
  402. //转执行
  403. case 2:
  404. //售前,审核通过,售前经理/管理员
  405. return (
  406. project_status == 0 &&
  407. audit_status == 3 &&
  408. (this.user.ID == author || this.user.IsSuper)
  409. );
  410. //转质保运营
  411. case 3:
  412. //执行,审核通过,执行经理/管理员
  413. return (
  414. project_status == 1 &&
  415. audit_status == 3 &&
  416. (this.user.ID == LeaderId || this.user.IsSuper)
  417. );
  418. }
  419. },
  420. onEdit() {
  421. uni.navigateTo({
  422. url: `./add?project_id=${this.currentProject.id}`,
  423. });
  424. },
  425. onDelete() {
  426. uni.showModal({
  427. title: "删除项目",
  428. content: "是否确认删除该项目",
  429. confirmText: "删除",
  430. confirmColor: "#ff7875",
  431. success: async (res) => {
  432. if (res.confirm) {
  433. await deleteApproval(this.currentProject);
  434. uni.showToast({
  435. title: "删除成功",
  436. });
  437. setTimeout(function () {
  438. uni.hideToast();
  439. uni.navigateTo({
  440. url: "./list",
  441. });
  442. }, 1800);
  443. }
  444. },
  445. });
  446. },
  447. onSubmitAuth() {
  448. uni.showModal({
  449. title: "提交审核",
  450. content: "是否确认提交审核",
  451. confirmText: "提审",
  452. success: async (res) => {
  453. if (res.confirm) {
  454. let payload = {
  455. id: this.currentProject.id,
  456. flow_id: this.currentProject.flow_id,
  457. node_id: this.currentProject.node_id,
  458. };
  459. await submitAudit(payload);
  460. uni.showToast({
  461. title: "提审成功",
  462. });
  463. setTimeout(function () {
  464. uni.hideToast();
  465. uni.navigateTo({
  466. url: "./list",
  467. });
  468. }, 1800);
  469. }
  470. },
  471. });
  472. },
  473. onMember() {
  474. uni.navigateTo({
  475. url: "./member",
  476. });
  477. },
  478. changeManager(e) {
  479. this.formData.manager = e.detail.value[e.detail.value.length - 1].value;
  480. },
  481. onExecute() {
  482. this.$refs.exePopup.open();
  483. return;
  484. },
  485. onWarranty() {
  486. this.$refs.wtyPopup.open();
  487. return;
  488. },
  489. async submitWarranty() {
  490. this.$refs.wty.validate(async (err) => {
  491. if (!err) {
  492. const [dep_id, manager_id] = this.formData.manager.split("-");
  493. let payload = {
  494. project_code_id: this.currentProject.id,
  495. dep_id: Number(dep_id),
  496. wty_manager_id: Number(manager_id),
  497. };
  498. await startWarranty(payload);
  499. uni.showToast({
  500. title: "转质保送审成功",
  501. });
  502. setTimeout(function () {
  503. uni.hideToast();
  504. uni.navigateTo({
  505. url: "./list",
  506. });
  507. }, 1800);
  508. }
  509. });
  510. },
  511. onOperate() {
  512. this.$refs.optPopup.open();
  513. return;
  514. },
  515. async submitOperate() {
  516. this.$refs.opt.validate(async (err) => {
  517. if (!err) {
  518. const [dep_id, manager_id] = this.formData.manager.split("-");
  519. let payload = {
  520. project_code_id: this.currentProject.id,
  521. dep_id: Number(dep_id),
  522. opt_manager_id: Number(manager_id),
  523. };
  524. await startOperate(payload);
  525. uni.showToast({
  526. title: "转运营送审成功",
  527. });
  528. setTimeout(function () {
  529. uni.hideToast();
  530. uni.navigateTo({
  531. url: "./list",
  532. });
  533. }, 1800);
  534. }
  535. });
  536. },
  537. // onCancel() {
  538. // this.$refs.exe.close();
  539. // this.$refs.wty.close();
  540. // this.$refs.opt.close();
  541. // }
  542. },
  543. };
  544. </script>
  545. <style lang="less" scoped>
  546. .content {
  547. display: flex;
  548. flex-wrap: wrap;
  549. }
  550. .main {
  551. width: 100%;
  552. padding-bottom: 60px;
  553. }
  554. .title {
  555. width: 100%;
  556. padding: 0 20px 20px 20px;
  557. font: 24px bold;
  558. }
  559. .list {
  560. margin: 0 10% 20px 10%;
  561. }
  562. .detail {
  563. width: 100%;
  564. padding: 15px 0;
  565. font-size: 18px;
  566. display: flex;
  567. justify-items: space-between;
  568. .subTitle {
  569. width: 30%;
  570. }
  571. .detailContent {
  572. width: 70%;
  573. }
  574. }
  575. ::v-deep {
  576. .uni-steps__column-title {
  577. font-size: 18px;
  578. line-height: 24px;
  579. }
  580. .uni-steps__column-desc {
  581. font-size: 14px;
  582. line-height: 18px;
  583. }
  584. }
  585. .editBtns {
  586. display: flex;
  587. justify-content: space-around;
  588. flex-wrap: wrap;
  589. margin: 0 5%;
  590. .edit {
  591. width: 30%;
  592. margin-bottom: 20px;
  593. font-size: 16px;
  594. text-align: center;
  595. }
  596. }
  597. .group {
  598. width: 100%;
  599. display: flex;
  600. position: fixed;
  601. flex-wrap: wrap;
  602. justify-content: flex-start;
  603. bottom: 0;
  604. left: 0;
  605. .commit {
  606. width: 50%;
  607. border-radius: 0;
  608. margin: inherit;
  609. }
  610. }
  611. .depSelect {
  612. width: 200px;
  613. }
  614. </style>