index.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556
  1. <template>
  2. <div class="ele-body">
  3. <el-card shadow="never">
  4. <index-search @search="reload"/>
  5. <!-- 数据表格 -->
  6. <ele-pro-table
  7. ref="table"
  8. row-key="id"
  9. :columns="columns"
  10. :datasource="datasource"
  11. height="calc(100vh - 400px)"
  12. full-height="calc(100vh - 116px)"
  13. :default-expand-all="true"
  14. cache-key="project-initiationTable"
  15. :selection.sync="selection"
  16. :tree-props="{children: 'projectList'}"
  17. @done="onDone"
  18. :indent="15"
  19. >
  20. <!-- :lazy="true"-->
  21. <!-- 表头工具栏 -->
  22. <template v-slot:toolbar>
  23. <el-button
  24. size="small"
  25. type="primary"
  26. icon="el-icon-plus"
  27. class="ele-btn-icon"
  28. @click="openEdit('','add')">
  29. 新建
  30. </el-button>
  31. <el-button
  32. size="small"
  33. type="danger"
  34. icon="el-icon-delete"
  35. class="ele-btn-icon"
  36. @click="allDelBtn"
  37. >
  38. 删除
  39. </el-button>
  40. <!-- <el-button-->
  41. <!-- size="small"-->
  42. <!-- type="danger"-->
  43. <!-- icon="el-icon-remove-outline"-->
  44. <!-- class="ele-btn-icon"-->
  45. <!-- @click="handleStatus('4')"-->
  46. <!-- >-->
  47. <!-- 终止-->
  48. <!-- </el-button>-->
  49. <!-- <el-button-->
  50. <!-- size="small"-->
  51. <!-- type="warning"-->
  52. <!-- icon="el-icon-video-play"-->
  53. <!-- class="ele-btn-icon"-->
  54. <!-- @click="handleStatus('2')"-->
  55. <!-- >-->
  56. <!-- 暂停-->
  57. <!-- </el-button>-->
  58. <!-- <el-button-->
  59. <!-- size="small"-->
  60. <!-- type="primary"-->
  61. <!-- icon="el-icon-video-pause"-->
  62. <!-- class="ele-btn-icon"-->
  63. <!-- @click="handleStatus('1')"-->
  64. <!-- >-->
  65. <!-- 启动-->
  66. <!-- </el-button>-->
  67. <!-- <el-button class="el-icon-sort" size="small" @click="expandAll">-->
  68. <!-- 展开/折叠-->
  69. <!-- </el-button>-->
  70. <!-- <div class="el-button--primary">122222</div> -->
  71. </template>
  72. <template v-slot:code="{ row }">
  73. <el-button type="text" @click="handelBOMConstructDetail(row,'view')">{{ row.code }}</el-button>
  74. </template>
  75. <template v-slot:status="{ row }">
  76. {{ getDictV('pro_projects_status', row.status) }}
  77. </template>
  78. <template v-slot:type="{ row }">
  79. {{ getDictV('pro_projects_type', row.type) }}
  80. </template>
  81. <template v-slot:isOverTime="{ row }">
  82. <el-tag v-if="row.isOverTime==0" type="success">正常</el-tag>
  83. <el-tag v-else type="danger">超时</el-tag>
  84. </template>
  85. <template v-slot:isOverbudget="{ row }">
  86. <el-tag v-if="row.isOverbudget==0" type="success">否</el-tag>
  87. <el-tag v-else type="danger">是</el-tag>
  88. </template>
  89. <template v-slot:speedPercent="{ row }">
  90. <el-progress :stroke-width="20" text-color="#606266" :text-inside="true" :percentage="row.speedPercent||0"
  91. :color="customColorMethod"></el-progress>
  92. </template>
  93. <!-- 操作列 -->
  94. <template v-slot:action="{ row }">
  95. <el-link
  96. type="primary"
  97. :underline="false"
  98. icon="el-icon-plus"
  99. @click="processSubmit(row)"
  100. v-if="[0, 3].includes(row.processStatus)"
  101. >
  102. 提交
  103. </el-link>
  104. <el-link
  105. type="primary"
  106. :underline="false"
  107. icon="el-icon-edit"
  108. v-if="[0, 3].includes(row.processStatus)"
  109. @click="openEdit(row,'edit')"
  110. >
  111. 修改
  112. </el-link>
  113. <el-popconfirm
  114. class="ele-action"
  115. title="确定要删除吗?"
  116. v-if="[0, 3].includes(row.processStatus)"
  117. @confirm="remove([row.id])">
  118. <template v-slot:reference>
  119. <el-link type="danger" :underline="false" icon="el-icon-delete">
  120. 删除
  121. </el-link>
  122. </template>
  123. </el-popconfirm>
  124. <el-dropdown trigger="click" >
  125. <span class="el-dropdown-link">
  126. 操作菜单<i class="el-icon-arrow-down el-icon--right"></i>
  127. </span>
  128. <el-dropdown-menu slot="dropdown">
  129. <el-dropdown-item v-if="![0,1, 3].includes(row.processStatus)&&![4,2,3].includes(row.status)">
  130. <el-link icon="el-icon-success" type="success" :underline="false" @click="handleStatus(projectsFinishAPI,'完成',row)">完成
  131. </el-link>
  132. </el-dropdown-item>
  133. <el-dropdown-item v-if="![0,1, 3].includes(row.processStatus)&&![4,2,3].includes(row.status)">
  134. <el-link icon="el-icon-video-pause" type="warning" :underline="false" @click="handleStatus(projectsPauseAPI,'暂停',row)">暂停
  135. </el-link>
  136. </el-dropdown-item>
  137. <el-dropdown-item v-if="![0,1, 3].includes(row.processStatus)&&![4,1,0,3].includes(row.status)">
  138. <el-link icon="el-icon-video-play" type="success" :underline="false" @click="handleStatus(projectsStartupAPI,'启动',row)">启动
  139. </el-link>
  140. </el-dropdown-item>
  141. <el-dropdown-item v-if="![0,1, 3].includes(row.processStatus)&&![4,3].includes(row.status)">
  142. <el-link icon="el-icon-error" type="danger" :underline="false" @click="handleStatus(projectsTerminationAPI,'终止',row)">终止</el-link>
  143. </el-dropdown-item>
  144. <el-dropdown-item>
  145. <el-link icon="el-icon-info" type="primary" :underline="false" @click="handelBOMConstructDetail(row)">
  146. 项目信息
  147. </el-link>
  148. </el-dropdown-item>
  149. <el-dropdown-item divided v-if="[0,1,2,3].includes(row.processStatus)&&[0,1].includes(row.status)">
  150. <el-link
  151. icon="el-icon-circle-plus"
  152. type="primary"
  153. :underline="false"
  154. @click="handleAddPlan(row)">
  155. 新增计划
  156. </el-link>
  157. </el-dropdown-item>
  158. </el-dropdown-menu>
  159. </el-dropdown>
  160. </template>
  161. </ele-pro-table>
  162. </el-card>
  163. <!-- 编辑弹窗 -->
  164. <add-or-edit-dialog v-if="addOrEditDialogFlag" @reload="reload" :addOrEditDialogFlag.sync="addOrEditDialogFlag"
  165. ref="addOrEditDialogRef"></add-or-edit-dialog>
  166. <detail-dialog v-if="detailDialogFlag" :detailDialogFlag.sync="detailDialogFlag"
  167. ref="detailDialogRef"></detail-dialog>
  168. <!-- 新增计划 -->
  169. <add-plan-dialog v-if="addPlanDialogFLag" @reload="reload" :addOrEditDialogFlag.sync="addPlanDialogFLag"
  170. ref="addPlanDialogRef"></add-plan-dialog>
  171. <!-- 多选删除弹窗 -->
  172. <pop-modal
  173. :visible.sync="delVisible"
  174. content="是否确定删除?"
  175. @done="commitBtn"
  176. />
  177. <process-submit-dialog :processSubmitDialogFlag.sync="processSubmitDialogFlag" v-if="processSubmitDialogFlag" ref="processSubmitDialogRef" @reload="reload"></process-submit-dialog>
  178. </div>
  179. </template>
  180. <script>
  181. import processSubmitDialog from "@/BIZComponents/processSubmitDialog/processSubmitDialog.vue";
  182. import indexSearch from "./components/index-search.vue";
  183. import addOrEditDialog from "./components/addOrEditDialog.vue";
  184. import addPlanDialog from "../planManage/components/addOrEditDialog.vue";
  185. import detailDialog from "./components/detailDialog.vue";
  186. import {projectsDeleteAPI, projectsPageAPI, submit,projectsFinishAPI,projectsPauseAPI,projectsStartupAPI,projectsTerminationAPI} from "@/api/project-manage";
  187. import {reviewStatusEnum} from '@/enum/dict';
  188. import {mapGetters} from "vuex";
  189. import {getByCode} from "@/api/system/dictionary-data";
  190. import popModal from "@/components/pop-modal/index.vue";
  191. export default {
  192. name: 'index',
  193. components: {
  194. popModal,
  195. addOrEditDialog,
  196. detailDialog,
  197. indexSearch,
  198. processSubmitDialog,
  199. addPlanDialog
  200. },
  201. computed: {
  202. ...mapGetters(['getDictValue']),
  203. columns() {
  204. return [
  205. {
  206. width: 45,
  207. type: 'selection',
  208. columnKey: 'selection',
  209. align: 'center'
  210. },
  211. {
  212. columnKey: 'index',
  213. label: '序号',
  214. type: 'index',
  215. width: 55,
  216. align: 'center',
  217. showOverflowTooltip: true,
  218. },
  219. {
  220. prop: 'type',
  221. label: '项目类型',
  222. showOverflowTooltip: true,
  223. minWidth: 150,
  224. align: 'center',
  225. slot: 'type',
  226. },
  227. {
  228. prop: 'code',
  229. label: '项目编码',
  230. showOverflowTooltip: true,
  231. minWidth: 160,
  232. slot: 'code',
  233. align: 'center',
  234. },
  235. {
  236. prop: 'name',
  237. label: '项目名称',
  238. align: 'center',
  239. showOverflowTooltip: true,
  240. minWidth: 140
  241. },
  242. {
  243. prop: 'responsibleDeptName',
  244. label: '负责部门',
  245. align: 'center',
  246. showOverflowTooltip: true,
  247. minWidth: 100
  248. },
  249. {
  250. prop: 'responsibleUserName',
  251. label: '项目经理',
  252. align: 'center',
  253. showOverflowTooltip: true,
  254. minWidth: 100
  255. },
  256. {
  257. prop: 'teamName',
  258. label: '项目团队',
  259. align: 'center',
  260. showOverflowTooltip: true,
  261. minWidth: 100
  262. },
  263. {
  264. prop: 'cycle',
  265. label: '项目周期',
  266. align: 'center',
  267. showOverflowTooltip: true,
  268. minWidth: 100
  269. },
  270. {
  271. prop: 'budget',
  272. label: '项目预算',
  273. align: 'center',
  274. showOverflowTooltip: true,
  275. minWidth: 110,
  276. formatter: (_row, _column, cellValue) => {
  277. return cellValue ? cellValue + this.getDictV('pro_projects_budget_unit', _row.unit) : '';
  278. }
  279. },
  280. {
  281. prop: 'planStartDate',
  282. label: '计划开始日期',
  283. align: 'center',
  284. showOverflowTooltip: true,
  285. minWidth: 120
  286. },
  287. {
  288. prop: 'planEndDate',
  289. label: '计划完成日期',
  290. align: 'center',
  291. showOverflowTooltip: true,
  292. minWidth: 120
  293. },
  294. {
  295. prop: 'realStartTime',
  296. label: '实际开始日期',
  297. align: 'center',
  298. showOverflowTooltip: true,
  299. minWidth: 120
  300. },
  301. {
  302. prop: 'realEndTime',
  303. label: '实际完成日期',
  304. align: 'center',
  305. showOverflowTooltip: true,
  306. minWidth: 120
  307. },
  308. {
  309. prop: 'cost',
  310. label: '费用(元)',
  311. align: 'center',
  312. showOverflowTooltip: true,
  313. minWidth: 140
  314. },
  315. {
  316. prop: 'status',
  317. label: '项目状态',
  318. align: 'center',
  319. showOverflowTooltip: true,
  320. minWidth: 100,
  321. slot: 'status',
  322. },
  323. {
  324. prop: 'processStatus',
  325. label: '审核状态',
  326. align: 'center',
  327. showOverflowTooltip: true,
  328. minWidth: 100,
  329. formatter: (_row, _column, cellValue) => {
  330. return reviewStatusEnum[_row.processStatus].label;
  331. }
  332. },
  333. {
  334. prop: 'isOverTime',
  335. label: '是否超时',
  336. align: 'center',
  337. showOverflowTooltip: true,
  338. minWidth: 100,
  339. slot: 'isOverTime'
  340. },
  341. {
  342. prop: 'isOverbudget',
  343. label: '是否超预算',
  344. align: 'center',
  345. showOverflowTooltip: true,
  346. minWidth: 100,
  347. slot: 'isOverbudget'
  348. },
  349. {
  350. prop: 'speedPercent',
  351. label: '项目进度',
  352. align: 'center',
  353. showOverflowTooltip: true,
  354. minWidth: 150,
  355. slot: 'speedPercent'
  356. },
  357. {
  358. columnKey: 'action',
  359. label: '操作',
  360. width: 200,
  361. align: 'center',
  362. resizable: false,
  363. slot: 'action',
  364. showOverflowTooltip: true,
  365. fixed: 'right'
  366. }
  367. ]
  368. },
  369. },
  370. data() {
  371. return {
  372. projectsFinishAPI:projectsFinishAPI,
  373. projectsPauseAPI:projectsPauseAPI,
  374. projectsStartupAPI:projectsStartupAPI,
  375. projectsTerminationAPI:projectsTerminationAPI,
  376. selection: [],
  377. dictList: [],
  378. // 表格列配置
  379. // 是否显示编辑弹窗
  380. addOrEditDialogFlag: false,
  381. detailDialogFlag: false,
  382. processSubmitDialogFlag: false,
  383. delVisible: false,
  384. addPlanDialogFLag: false,
  385. // 全部菜单数据
  386. menuList: [],
  387. // 展开折叠
  388. expandAllFlag: false,
  389. };
  390. },
  391. async created() {
  392. },
  393. methods: {
  394. getDictV(code, val) {
  395. if (!this.dictList[code]) return '';
  396. return this.dictList[code].find(item => item.value == val)?.label
  397. },
  398. async getDictList(code) {
  399. let {data: res} = await getByCode(code)
  400. this.dictList[code] = res.map(item => {
  401. let values = Object.keys(item)
  402. return {
  403. value: values[0],
  404. label: item[values[0]]
  405. }
  406. })
  407. },
  408. handelBOMConstructDetail(row,type='') {
  409. this.$router.push({
  410. path: '/BOMmanage/details',
  411. query: {
  412. id: row.id,
  413. type
  414. }
  415. });
  416. },
  417. customColorMethod(percentage) {
  418. if (percentage < 30) {
  419. return '#909399';
  420. } else if (percentage < 70) {
  421. return '#e6a23c';
  422. } else {
  423. return '#67c23a';
  424. }
  425. },
  426. /* 表格数据源 */
  427. async datasource({page, limit, where, parent}) {
  428. await this.getDictList('pro_projects_status')
  429. await this.getDictList('pro_projects_type')
  430. await this.getDictList('pro_projects_budget_unit')
  431. return projectsPageAPI({
  432. pageNum: page,
  433. size: limit,
  434. parentId: parent?.id ?? '0',
  435. ...where
  436. });
  437. },
  438. onDone(row) {
  439. console.log(row);
  440. },
  441. /* 刷新表格 */
  442. reload(where) {
  443. this.$refs.table.reload({where, size: 1, pageNum: 10, parentId: '0'});
  444. this.$refs.table.reRenderTable()
  445. },
  446. /* 显示编辑 */
  447. openEdit(row = {}, type) {
  448. this.addOrEditDialogFlag = true;
  449. this.$nextTick(() => {
  450. this.$refs.addOrEditDialogRef.init(row, type)
  451. })
  452. },
  453. openDetail(row = {}) {
  454. this.detailDialogFlag = true;
  455. this.$nextTick(() => {
  456. this.$refs.detailDialogRef.init(row)
  457. })
  458. },
  459. handleAddPlan(row) {
  460. this.addPlanDialogFLag = true;
  461. this.$nextTick(() => {
  462. row.projectId = row.id
  463. this.$refs.addPlanDialogRef.init(row, 'add')
  464. })
  465. },
  466. async handleStatus(API, msg, row) {
  467. let message = '确定' + msg + '该项目吗';
  468. this.$confirm(message, '提示', {
  469. type: 'warning'
  470. }).then(async () => {
  471. await API(row.id)
  472. this.$message.success('操作成功');
  473. this.reload();
  474. }).catch(() => {
  475. });
  476. },
  477. //流程提交
  478. processSubmit(row) {
  479. this.processSubmitDialogFlag = true
  480. this.$nextTick(()=>{
  481. let params = {
  482. businessId:row.id,
  483. businessKey : 'pro_project_approve',
  484. }
  485. this.$refs.processSubmitDialogRef.init(params)
  486. })
  487. // submit({
  488. // projectId: row.id
  489. // }).then((res) => {
  490. // this.$message.success('提交成功');
  491. // this.reload();
  492. // });
  493. },
  494. //批量删除
  495. allDelBtn() {
  496. if (this.selection.length === 0) return;
  497. let flag = this.selection.some(item => [1, 2].includes(item.processStatus))
  498. if (flag) return this.$message.warning('抱歉已审核、审核中的数据不能删除,请检查')
  499. this.delVisible = true;
  500. },
  501. //删除弹框确定
  502. commitBtn() {
  503. const dataId = this.selection.map((v) => v.id);
  504. this.remove(dataId);
  505. },
  506. /* 删除 */
  507. remove(ids) {
  508. const loading = this.$loading({lock: true});
  509. projectsDeleteAPI(ids)
  510. .then((res) => {
  511. loading.close();
  512. this.$message.success('删除成功');
  513. this.reload();
  514. })
  515. .catch((e) => {
  516. loading.close();
  517. // this.$message.error(e.message);
  518. });
  519. },
  520. /* 展开/折叠全部 */
  521. expandAll() {
  522. this.expandAllFlag = !this.expandAllFlag;
  523. this.$refs.table.toggleRowExpansionAll(this.expandAllFlag);
  524. },
  525. }
  526. };
  527. </script>
  528. <style lang="scss" scoped>
  529. ::v-deep .el-dropdown-link {
  530. cursor: pointer;
  531. color: #188ffd;
  532. }
  533. ::v-deep .el-dropdown-menu__item{
  534. .el-link{
  535. width: 100%;
  536. display: flex;
  537. flex: 1;
  538. justify-content: flex-start;
  539. }
  540. }
  541. </style>