detail.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457
  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. </view>
  132. </template>
  133. <script>
  134. import { mapState } from "vuex";
  135. import {
  136. queryFlow,
  137. deleteApproval,
  138. submitAudit,
  139. queryUserDetail,
  140. authApproval,
  141. } from "@/services/project";
  142. export default {
  143. data() {
  144. return {
  145. auth: false,
  146. status: ["售前", "转执行", "转运营", "转质保"],
  147. flowList: [],
  148. depRole: [],
  149. user: {},
  150. };
  151. },
  152. computed: {
  153. ...mapState(["currentProject"]),
  154. nodeList() {
  155. if (!this.flowList) return [];
  156. let flowInfo = this.flowList.find(
  157. (item) => item.id == this.currentProject.flow_id
  158. );
  159. if (!flowInfo) return [];
  160. let currentIndex = flowInfo.Nodes.findIndex(
  161. (item) => item.id == this.currentProject.node_id
  162. );
  163. return {
  164. currentIndex,
  165. list: flowInfo.Nodes.map((item) => ({
  166. title: item.node,
  167. desc: `审批人:${this.getAudits(item)}`,
  168. })),
  169. };
  170. },
  171. },
  172. onLoad(options) {
  173. this.auth = Boolean(options.auth);
  174. this.init();
  175. },
  176. methods: {
  177. async init() {
  178. this.user = uni.getStorageSync("user");
  179. let res;
  180. res = await queryFlow();
  181. this.flowList = res.data;
  182. res = await queryUserDetail(this.user);
  183. let depId = this.user.DepId;
  184. let dep = res.data.Dep.find((item) => item.ID == depId);
  185. this.depRole = dep.Role;
  186. },
  187. canAuth() {
  188. let { NodeInfo, audit_status, project_status } = this.currentProject;
  189. if (!NodeInfo || this.flowList.length == 0 || this.depRole.length == 0)
  190. return false;
  191. if (audit_status != 1) return false;
  192. if (project_status == 2)
  193. return this.currentProject.opt_manager_id == this.user.ID;
  194. if (project_status == 3)
  195. return this.currentProject.wty_manager_id == this.user.ID;
  196. let flow = this.flowList.find((item) => item.id == NodeInfo.flow_id);
  197. if (!flow) return false;
  198. let { NodeAudits } = flow.Nodes.find((item) => item.id == NodeInfo.id);
  199. const role = this.depRole.find((item) =>
  200. NodeAudits.find((audit) => audit.audit_role == item.ID)
  201. );
  202. return Boolean(role);
  203. },
  204. onHandleAudit(value) {
  205. if (value) {
  206. uni.showModal({
  207. title: "审批通过",
  208. content: "是否确认通过审批",
  209. confirmText: "通过",
  210. success: async (res) => {
  211. if (res.confirm) {
  212. let payload = {
  213. id: this.currentProject.id,
  214. project_full_code: this.currentProject.project_full_code,
  215. flow_id: this.currentProject.flow_id,
  216. node_id: this.currentProject.node_id,
  217. audit_status: 3,
  218. audit_comment: "",
  219. };
  220. await authApproval(payload);
  221. uni.showToast({
  222. title: "审核成功",
  223. });
  224. setTimeout(function () {
  225. uni.hideToast();
  226. uni.navigateTo({
  227. url: "./auth",
  228. });
  229. }, 1800);
  230. }
  231. },
  232. });
  233. } else console.log("审核拒绝");
  234. },
  235. getAudits(nodeInfo) {
  236. switch (nodeInfo.id) {
  237. case 11:
  238. return "执行项目经理";
  239. case 12:
  240. return "运营经理";
  241. case 13:
  242. return "执行项目经理";
  243. case 14:
  244. return "质保经理";
  245. default:
  246. return (nodeInfo.NodeAudits || [])
  247. .map((item) => item.AuthorRoleInfo.Name)
  248. .join(",");
  249. }
  250. },
  251. canEdit(index) {
  252. let {
  253. audit_status,
  254. project_status,
  255. author,
  256. LeaderId,
  257. opt_manager_id,
  258. wty_manager_id,
  259. } = this.currentProject;
  260. //audit_status: 0未提审1审核中2审核拒绝3审核通过
  261. //project_status: 0售前1执行2转运营3转质保
  262. switch (index) {
  263. //编辑删除提审
  264. case 0:
  265. //售前阶段,未提审/审核被拒,创建人/管理员
  266. return (
  267. project_status == 0 &&
  268. (audit_status == 0 || audit_status == 2) &&
  269. (this.user.ID == author || this.user.IsSuper)
  270. );
  271. //成员管理
  272. case 1:
  273. //售前/执行/运营/质保,审核通过,项目经理/管理员
  274. let manager;
  275. switch (project_status) {
  276. case 0:
  277. manager = author;
  278. break;
  279. case 1:
  280. manager = LeaderId;
  281. break;
  282. case 2:
  283. manager = opt_manager_id;
  284. break;
  285. case 3:
  286. manager = wty_manager_id;
  287. break;
  288. }
  289. return (
  290. audit_status == 3 && (this.user.ID == manager || this.user.IsSuper)
  291. );
  292. //转执行
  293. case 2:
  294. //售前,审核通过,售前经理/管理员
  295. return (
  296. project_status == 0 &&
  297. audit_status == 3 &&
  298. (this.user.ID == author || this.user.IsSuper)
  299. );
  300. //转质保运营
  301. case 3:
  302. //执行,审核通过,执行经理/管理员
  303. return (
  304. project_status == 1 &&
  305. audit_status == 3 &&
  306. (this.user.ID == LeaderId || this.user.IsSuper)
  307. );
  308. }
  309. },
  310. onEdit() {
  311. uni.navigateTo({
  312. url: `./add?project_id=${this.currentProject.id}`,
  313. });
  314. },
  315. onDelete() {
  316. uni.showModal({
  317. title: "删除项目",
  318. content: "是否确认删除该项目",
  319. confirmText: "删除",
  320. confirmColor: "#ff7875",
  321. success: async (res) => {
  322. if (res.confirm) {
  323. await deleteApproval(this.currentProject);
  324. uni.showToast({
  325. title: "删除成功",
  326. });
  327. setTimeout(function () {
  328. uni.hideToast();
  329. uni.navigateTo({
  330. url: "./list",
  331. });
  332. }, 1800);
  333. }
  334. },
  335. });
  336. },
  337. onSubmitAuth() {
  338. uni.showModal({
  339. title: "提交审核",
  340. content: "是否确认提交审核",
  341. confirmText: "提审",
  342. success: async (res) => {
  343. if (res.confirm) {
  344. let payload = {
  345. id: this.currentProject.id,
  346. flow_id: this.currentProject.flow_id,
  347. node_id: this.currentProject.node_id,
  348. };
  349. console.log(payload);
  350. await submitAudit(payload);
  351. uni.showToast({
  352. title: "提审成功",
  353. });
  354. setTimeout(function () {
  355. uni.hideToast();
  356. uni.navigateTo({
  357. url: "./list",
  358. });
  359. }, 1800);
  360. }
  361. },
  362. });
  363. },
  364. onMember() {
  365. uni.navigateTo({
  366. url: "./member",
  367. });
  368. },
  369. onExecute() {
  370. return;
  371. },
  372. onWarranty() {
  373. return;
  374. },
  375. onOperate() {
  376. return;
  377. },
  378. },
  379. };
  380. </script>
  381. <style lang="less" scoped>
  382. .content {
  383. display: flex;
  384. flex-wrap: wrap;
  385. }
  386. .main {
  387. padding-bottom: 60px;
  388. }
  389. .title {
  390. width: 100%;
  391. padding: 0 20px 20px 20px;
  392. font: 24px bold;
  393. }
  394. .list {
  395. margin: 0 10% 20px 10%;
  396. width: 100%;
  397. }
  398. .detail {
  399. width: 100%;
  400. padding: 15px 0;
  401. font-size: 18px;
  402. display: flex;
  403. justify-items: space-between;
  404. .subTitle {
  405. width: 30%;
  406. }
  407. .detailContent {
  408. width: 70%;
  409. }
  410. }
  411. ::v-deep {
  412. .uni-steps__column-title {
  413. font-size: 18px;
  414. line-height: 24px;
  415. }
  416. .uni-steps__column-desc {
  417. font-size: 14px;
  418. line-height: 18px;
  419. }
  420. }
  421. .editBtns {
  422. display: flex;
  423. justify-content: space-around;
  424. flex-wrap: wrap;
  425. margin: 0 5%;
  426. .edit {
  427. width: 30%;
  428. margin-bottom: 20px;
  429. font-size: 16px;
  430. text-align: center;
  431. }
  432. }
  433. .group {
  434. width: 100%;
  435. display: flex;
  436. position: fixed;
  437. flex-wrap: wrap;
  438. justify-content: flex-start;
  439. bottom: 0;
  440. left: 0;
  441. .commit {
  442. width: 50%;
  443. border-radius: 0;
  444. margin: inherit;
  445. }
  446. }
  447. </style>