edit.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414
  1. <template>
  2. <view>
  3. <view class="card-wrapper">
  4. <uni-card title="操作">
  5. <view class="editBtns" slot="actions">
  6. <view class="edit" @click="onClickProject">项目详情</view>
  7. <view class="edit" v-if="canEdit(0)" @click="onEdit">编辑</view>
  8. <view class="edit" v-if="canEdit(0)" @click="onDelete">删除</view>
  9. <view class="edit" v-if="canEdit(0)" @click="onSubmitAuth">
  10. 提交审核
  11. </view>
  12. <view class="edit" v-if="canEdit(1)" @click="onMember">
  13. 成员管理
  14. </view>
  15. <view class="edit" v-if="canEdit(2)" @click="onExecute">
  16. 转执行
  17. </view>
  18. <view class="edit" v-if="canEdit(3)" @click="onWarranty">
  19. 转质保
  20. </view>
  21. <view class="edit" v-if="canEdit(3)" @click="onOperate">
  22. 转运营
  23. </view>
  24. </view>
  25. </uni-card>
  26. </view>
  27. <uni-popup ref="exePopup" type="dialog">
  28. <uni-popup-dialog
  29. title="转执行"
  30. type="info"
  31. @confirm="submitExecute"
  32. @close="onCancel"
  33. before-close
  34. >
  35. <uni-forms
  36. ref="exe"
  37. :modelValue="formData"
  38. label-position="left"
  39. :rules="exeRules"
  40. >
  41. <uni-forms-item required label="执行经理:" name="manager">
  42. <uni-data-picker
  43. class="depSelect"
  44. placeholder="请选择执行经理"
  45. :localdata="depUserTree"
  46. @change="changeManager"
  47. />
  48. </uni-forms-item>
  49. <uni-forms-item required label="合同状态:" name="contract">
  50. <picker
  51. @change="changeContract"
  52. :range="contracts"
  53. :value="formData.contract"
  54. >
  55. <view class="select">{{ contracts[formData.contract] }}</view>
  56. </picker>
  57. </uni-forms-item>
  58. </uni-forms>
  59. </uni-popup-dialog>
  60. </uni-popup>
  61. <uni-popup ref="wtyPopup" type="dialog">
  62. <uni-popup-dialog
  63. title="转质保"
  64. type="info"
  65. @confirm="submitWarranty"
  66. @close="onCancel"
  67. before-close
  68. >
  69. <uni-forms
  70. ref="wty"
  71. :modelValue="formData"
  72. label-position="left"
  73. :rules="wtyRules"
  74. >
  75. <uni-forms-item required label="质保经理:" name="manager">
  76. <uni-data-picker
  77. class="depSelect"
  78. placeholder="请选择质保经理"
  79. :localdata="depUserTree"
  80. @change="changeManager"
  81. />
  82. </uni-forms-item>
  83. </uni-forms>
  84. </uni-popup-dialog>
  85. </uni-popup>
  86. <uni-popup ref="optPopup" type="dialog">
  87. <uni-popup-dialog
  88. title="转运营"
  89. type="info"
  90. @confirm="submitOperate"
  91. @close="onCancel"
  92. before-close
  93. >
  94. <uni-forms
  95. ref="opt"
  96. :modelValue="formData"
  97. label-position="left"
  98. :rules="optRules"
  99. >
  100. <uni-forms-item required label="运营经理:" name="manager">
  101. <uni-data-picker
  102. class="depSelect"
  103. placeholder="请选择运营经理"
  104. :localdata="depUserTree"
  105. @change="changeManager"
  106. />
  107. </uni-forms-item>
  108. </uni-forms>
  109. </uni-popup-dialog>
  110. </uni-popup>
  111. </view>
  112. </template>
  113. <script>
  114. import { mapState } from "vuex";
  115. import {
  116. deleteApproval,
  117. submitAudit,
  118. startExecution,
  119. startWarranty,
  120. startOperate,
  121. } from "@/services/project";
  122. export default {
  123. props: ["project", "user"],
  124. computed: {
  125. ...mapState(["depUserTree", "showSearch"]),
  126. },
  127. data() {
  128. return {
  129. contracts: ["无合同", "有合同"],
  130. formData: {
  131. manager: "",
  132. contract: null,
  133. },
  134. exeRules: {
  135. manager: {
  136. rules: [{ required: true, errorMessage: "请选择质保经理" }],
  137. },
  138. contract: {
  139. rules: [{ required: true, errorMessage: "请选择合同状态" }],
  140. },
  141. },
  142. wtyRules: {
  143. manager: {
  144. rules: [{ required: true, errorMessage: "请选择质保经理" }],
  145. },
  146. },
  147. optRules: {
  148. manager: {
  149. rules: [{ required: true, errorMessage: "请选择运营经理" }],
  150. },
  151. },
  152. };
  153. },
  154. methods: {
  155. async onClickProject() {
  156. await this.$store.commit("setCurrentProject", this.project);
  157. uni.navigateTo({
  158. url: `./detail?id=${this.project.id}`,
  159. });
  160. },
  161. canEdit(index) {
  162. let {
  163. audit_status,
  164. project_status,
  165. author,
  166. LeaderId,
  167. opt_manager_id,
  168. wty_manager_id,
  169. } = this.project;
  170. //audit_status: 0未提审1审核中2审核拒绝3审核通过
  171. //project_status: 0售前1执行2转运营3转质保
  172. switch (index) {
  173. //编辑删除提审
  174. case 0:
  175. //售前阶段,未提审/审核被拒,创建人/管理员
  176. return (
  177. project_status == 0 &&
  178. (audit_status == 0 || audit_status == 2) &&
  179. (this.user.ID == author || this.user.IsSuper)
  180. );
  181. //成员管理
  182. case 1:
  183. //售前/执行/运营/质保,审核通过,项目经理/管理员
  184. let manager;
  185. switch (project_status) {
  186. case 0:
  187. manager = this.user.ID == author;
  188. break;
  189. case 1:
  190. manager = this.user.ID == LeaderId;
  191. break;
  192. case 2:
  193. manager =
  194. this.user.ID == LeaderId || this.user.ID == opt_manager_id;
  195. break;
  196. case 3:
  197. manager =
  198. this.user.ID == LeaderId || this.user.ID == wty_manager_id;
  199. break;
  200. }
  201. return audit_status == 3 && (manager || this.user.IsSuper);
  202. //转执行
  203. case 2:
  204. //售前,审核通过,售前经理/管理员
  205. return (
  206. project_status == 0 &&
  207. audit_status == 3 &&
  208. (this.user.ID == author || this.user.IsSuper)
  209. );
  210. //转质保运营
  211. case 3:
  212. //执行,审核通过,执行经理/管理员
  213. return (
  214. project_status == 1 &&
  215. audit_status == 3 &&
  216. (this.user.ID == LeaderId || this.user.IsSuper)
  217. );
  218. }
  219. },
  220. async onEdit() {
  221. await this.$store.commit("setCurrentProject", this.project);
  222. uni.navigateTo({
  223. url: `./add?project_id=${this.project.id}`,
  224. });
  225. },
  226. onDelete() {
  227. uni.showModal({
  228. title: "删除项目",
  229. content: "是否确认删除该项目",
  230. confirmText: "删除",
  231. confirmColor: "#ff7875",
  232. success: async (res) => {
  233. if (res.confirm) {
  234. await deleteApproval(this.project);
  235. uni.showToast({
  236. title: "删除成功",
  237. });
  238. setTimeout(function () {
  239. uni.hideToast();
  240. location.reload();
  241. }, 1800);
  242. }
  243. },
  244. });
  245. },
  246. onSubmitAuth() {
  247. uni.showModal({
  248. title: "提交审核",
  249. content: "是否确认提交审核",
  250. confirmText: "提审",
  251. success: async (res) => {
  252. if (res.confirm) {
  253. let payload = {
  254. id: this.project.id,
  255. flow_id: this.project.flow_id,
  256. node_id: this.project.node_id,
  257. };
  258. await submitAudit(payload);
  259. uni.showToast({
  260. title: "提审成功",
  261. });
  262. setTimeout(function () {
  263. uni.hideToast();
  264. location.reload();
  265. }, 1800);
  266. }
  267. },
  268. });
  269. },
  270. async onMember() {
  271. await this.$store.commit("setCurrentProject", this.project);
  272. uni.navigateTo({
  273. url: "./member",
  274. });
  275. },
  276. changeManager(e) {
  277. if (e.detail.value.length > 0)
  278. this.formData.manager = e.detail.value[e.detail.value.length - 1].value;
  279. else this.formData.manager = "";
  280. },
  281. async onExecute() {
  282. await this.$store.commit("setShowSearch", false);
  283. this.$refs.exePopup.open();
  284. },
  285. changeContract(e) {
  286. this.formData.contract = e.detail.value;
  287. },
  288. async submitExecute() {
  289. this.$refs.exe.validate(async (err) => {
  290. if (!err) {
  291. const [dep_id, manager_id] = this.formData.manager.split("-");
  292. let payload = {
  293. project_code_id: this.project.id,
  294. with_contract: Number(this.formData.contract),
  295. dep_id: Number(dep_id),
  296. exe_manager_id: Number(manager_id),
  297. };
  298. await startExecution(payload);
  299. this.$refs.exePopup.close();
  300. uni.showToast({
  301. title: "转执行送审成功",
  302. });
  303. setTimeout(function () {
  304. uni.hideToast();
  305. location.reload();
  306. }, 1800);
  307. }
  308. });
  309. },
  310. async onWarranty() {
  311. await this.$store.commit("setShowSearch", false);
  312. this.$refs.wtyPopup.open();
  313. },
  314. async submitWarranty() {
  315. this.$refs.wty.validate(async (err) => {
  316. if (!err) {
  317. const [dep_id, manager_id] = this.formData.manager.split("-");
  318. let payload = {
  319. project_code_id: this.project.id,
  320. dep_id: Number(dep_id),
  321. wty_manager_id: Number(manager_id),
  322. };
  323. await startWarranty(payload);
  324. this.$refs.wtyPopup.close();
  325. uni.showToast({
  326. title: "转质保送审成功",
  327. });
  328. setTimeout(function () {
  329. uni.hideToast();
  330. location.reload();
  331. }, 1800);
  332. }
  333. });
  334. },
  335. async onOperate() {
  336. await this.$store.commit("setShowSearch", false);
  337. this.$refs.optPopup.open();
  338. },
  339. async submitOperate() {
  340. this.$refs.opt.validate(async (err) => {
  341. if (!err) {
  342. const [dep_id, manager_id] = this.formData.manager.split("-");
  343. let payload = {
  344. project_code_id: this.project.id,
  345. dep_id: Number(dep_id),
  346. opt_manager_id: Number(manager_id),
  347. };
  348. await startOperate(payload);
  349. this.$refs.optPopup.close();
  350. uni.showToast({
  351. title: "转运营送审成功",
  352. });
  353. setTimeout(function () {
  354. uni.hideToast();
  355. location.reload();
  356. }, 1800);
  357. }
  358. });
  359. },
  360. async onCancel() {
  361. await this.$store.commit("setShowSearch", true);
  362. this.$refs.exePopup.close();
  363. this.$refs.wtyPopup.close();
  364. this.$refs.optPopup.close();
  365. this.formData = {
  366. manager: "",
  367. contract: null,
  368. };
  369. },
  370. },
  371. };
  372. </script>
  373. <style lang="less" scoped>
  374. .editBtns {
  375. display: flex;
  376. justify-content: space-around;
  377. flex-wrap: wrap;
  378. margin: 0 5%;
  379. .edit {
  380. width: 30%;
  381. margin-bottom: 20px;
  382. font-size: 28rpx;
  383. text-align: center;
  384. }
  385. }
  386. .card-wrapper {
  387. padding-bottom: 60rpx;
  388. }
  389. .select {
  390. width: 100%;
  391. height: 72rpx;
  392. line-height: 70rpx;
  393. border: 1px solid #666;
  394. padding-left: 20rpx;
  395. }
  396. ::v-deep {
  397. .uni-steps__column-title {
  398. font-size: 18px;
  399. line-height: 24px;
  400. }
  401. .uni-steps__column-desc {
  402. font-size: 14px;
  403. line-height: 18px;
  404. }
  405. }
  406. .depSelect {
  407. width: 200px;
  408. }
  409. </style>