list.vue 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692
  1. <template>
  2. <section>
  3. <!--工具条-->
  4. <el-col :span="24" class="toolbar" style="padding-bottom: 0px;">
  5. <el-form :inline="true">
  6. <div style="margin-left: 20px;display: inline-block">
  7. <el-form-item label="任务列表">
  8. </el-form-item>
  9. </div>
  10. <el-form-item >
  11. <div style="margin-left: 8px">
  12. <!-- <el-input style="float:left;" v-model="keyword" class="input-with-select" placeholder="请输入项目名称关键字" clearable="true"> -->
  13. <el-select v-model="searchField" style="width:120px;" slot="prepend" placeholder="请选择">
  14. <el-option label="进行中" value="0" @click.native="hiddens()"></el-option>
  15. <el-option label="已完成" value="1" @click.native="hiddens()"></el-option>
  16. </el-select>
  17. <!-- <el-button slot="append" @click="searchList" icon="el-icon-search"></el-button> -->
  18. <!-- </el-input> -->
  19. </div>
  20. </el-form-item>
  21. <!-- <el-form-item style="float:right;">
  22. <el-link type="primary" :underline="false" @click="handleAdd(-1,null)">新增任务</el-link>
  23. </el-form-item> -->
  24. </el-form>
  25. </el-col>
  26. <div style="display: flex;width: 100%;">
  27. <div class="classification">
  28. <div>
  29. <p :class="idx == 1 ? 'on' : ''" @click="switchs(1)">我负责的</p>
  30. <p :class="idx == 2 ? 'on' : ''" @click="switchs(2)">我创建的</p>
  31. </div>
  32. </div>
  33. <div style="max-width: 94%;min-width: 90%">
  34. <!--列表-->
  35. <el-table :data="list" highlight-current-row v-loading="listLoading" :height="tableHeight" style="width: 100%;">
  36. <el-table-column type="index" width="60">
  37. <template slot-scope="scope" >
  38. {{scope.$index+1+(page-1)*size}}
  39. </template>
  40. </el-table-column>
  41. <el-table-column prop="name" label="任务名称" sortable width="350">
  42. <template slot-scope="scope">
  43. <el-popover trigger="hover" placement="top" width="350" v-if="scope.row.name">
  44. <p id="caseContent">{{scope.row.name}}</p>
  45. <div slot="reference" class="name-wrapper">
  46. <div class="cal">{{scope.row.name}}</div>
  47. </div>
  48. </el-popover>
  49. </template>
  50. </el-table-column>
  51. <el-table-column prop="projectName" label="项目名称" sortable width="350"></el-table-column>
  52. <el-table-column prop="executorName" label="负责人" sortable width="250">
  53. <template slot-scope="scope">
  54. <el-link type="primary" @click="showUser(scope.row.executorId)">{{scope.row.executorName}}</el-link>
  55. </template>
  56. </el-table-column>
  57. <el-table-column prop="stagesName" label="项目阶段" sortable width="350" @mouseover="mouseOver">
  58. <!-- <template slot-scope="scope">
  59. <el-popover trigger="click" placement="top" width="450" v-if="scope.row.taskDesc">
  60. <p v-html='scope.row.taskDesc'></p>
  61. <div slot="reference" class="name-wrapper">
  62. <div class="acl" v-html='scope.row.taskDesc'></div>
  63. </div>
  64. </el-popover>
  65. </template> -->
  66. </el-table-column>
  67. <el-table-column prop="createDate" label="创建时间" sortable width="250"></el-table-column>
  68. <el-table-column label="截止时间" width="290" fixed="right">
  69. <template slot-scope="scope">
  70. <div style="display: flex;justify-content: space-between;padding-right: 40px">
  71. <span style="display: inline-block;margin-right: 55px">{{scope.row.endDate}}</span>
  72. <el-button v-if="searchField == 0" size="small" type="primary" @click="completes(scope.row.id, 0)">完成</el-button>
  73. <el-button v-if="searchField == 1" size="small" type="warning" @click="completes(scope.row.id, 1)">重启</el-button>
  74. </div>
  75. </template>
  76. </el-table-column>
  77. </el-table>
  78. <!--工具条-->
  79. <el-col :span="24" class="toolbar">
  80. <el-pagination
  81. @size-change="handleSizeChange"
  82. @current-change="handleCurrentChange"
  83. :page-sizes="[20 , 50 , 80 , 100]"
  84. :page-size="20"
  85. layout="total, sizes, prev, pager, next"
  86. :total="total"
  87. style="float:right;"
  88. ></el-pagination>
  89. </el-col>
  90. </div>
  91. </div>
  92. <!--新增界面-->
  93. <el-dialog :title="title" v-if="addFormVisible" :visible.sync="addFormVisible" :close-on-click-modal="false" customClass="customWidth" width="600px">
  94. <el-form ref="form1" :model="addForm" :rules="rules" label-width="100px">
  95. <el-form-item label="任务名称" >
  96. <el-input v-model="addForm.code" :disabled="user.role==0" placeholder="请输入项目编号" clearable></el-input>
  97. </el-form-item>
  98. <el-form-item label="项目名称" prop="name">
  99. <el-input v-model="addForm.name" :disabled="user.role==0" placeholder="请输入项目名称" clearable></el-input>
  100. </el-form-item>
  101. <el-form-item label="全部参与者">
  102. <el-select v-model="addForm.userId" multiple filterable placeholder="请选择参与者" style="width:100%;" @change="changeParticipator">
  103. <el-option v-for="item in users" :key="item.id" :label="item.name" :value="item.id"></el-option>
  104. </el-select>
  105. </el-form-item>
  106. <el-form-item label="主要负责人" >
  107. <el-select v-model="addForm.inchargerId" :disabled="addForm.userId.length==0 || user.role==0" filterable placeholder="请选择负责人" style="width:100%;" @change="changeIncharger">
  108. <el-option v-for="item in participator" :key="item.id" :label="item.name" :value="item.id"></el-option>
  109. </el-select>
  110. </el-form-item>
  111. </el-form>
  112. <div slot="footer" class="dialog-footer">
  113. <el-button @click.native="addFormVisible = false">取消</el-button>
  114. <el-button type="primary" @click="submitInsert" :loading="addLoading">提交</el-button>
  115. </div>
  116. </el-dialog>
  117. <!--用户详细信息弹出框-->
  118. <el-dialog title="查看详情" v-if="userDetailVisible" :visible.sync="userDetailVisible" :close-on-click-modal="false" customClass="customWidth" width="400px">
  119. <div class="line"><span>姓名</span><span>{{userDetail.name}}</span></div>
  120. <div class="line"><span>手机号码</span><span>{{userDetail.phone}}</span></div>
  121. <div class="line"><span>部门</span><span>{{userDetail.departmentName}}</span></div>
  122. <div class="line"><span>成本</span><span>{{userDetail.cost}}元/小时</span></div>
  123. <div slot="footer" class="dialog-footer">
  124. <el-button type="primary" @click="userDetailVisible = false" >确定</el-button>
  125. </div>
  126. </el-dialog>
  127. <!-- 子项目列表 -->
  128. <el-dialog title="子项目列表" show-header="false" v-if="subProjectVisible" :visible.sync="subProjectVisible" :close-on-click-modal="false" customClass="customWidth" width="500px">
  129. <el-table :data="subProjectList" highlight-current-row height="400" style="width: 100%;">
  130. <el-table-column type="index" width="60" label="序号">
  131. <template slot-scope="scope" >
  132. {{scope.$index+1+(page-1)*size}}
  133. </template>
  134. </el-table-column>
  135. <el-table-column prop="name" label="名称" ></el-table-column>
  136. <el-table-column label="操作" width="150">
  137. <template slot-scope="scope" >
  138. <el-button size="small" type="primary" @click="addNewSubProject(scope.row)">编辑</el-button>
  139. <el-button size="small" type="danger" @click="deleteSubPro(scope.row)">删除</el-button>
  140. </template>
  141. </el-table-column>
  142. </el-table>
  143. <div slot="footer" class="dialog-footer">
  144. <el-button type="primary" @click="subProjectVisible = false" >关闭</el-button>
  145. <el-button type="primary" @click="addNewSubProject()" >新增子项目</el-button>
  146. </div>
  147. </el-dialog>
  148. <!-- 新增子项目弹出框 -->
  149. <el-dialog title="新增/修改子项目" v-if="addSubProject" :visible.sync="addSubProject" :close-on-click-modal="false" customClass="customWidth" width="500px">
  150. <el-form ref="form2" :model="addForm" :rules="rules" label-width="100px">
  151. <el-form-item label="项目名称" prop="name">
  152. <el-input v-model="addForm.name" placeholder="请输入项目名称" clearable></el-input>
  153. </el-form-item>
  154. </el-form>
  155. <div slot="footer" class="dialog-footer">
  156. <el-button @click.native="addSubProject = false">取消</el-button>
  157. <el-button type="primary" @click="submitInsertSubProject" :loading="addLoading">提交</el-button>
  158. </div>
  159. </el-dialog>
  160. </section>
  161. </template>
  162. <style scoped>
  163. .input-with-select .el-input-group__prepend {
  164. background-color: #fff;
  165. }
  166. .line {
  167. padding:10px;
  168. }
  169. .line span{
  170. font-size:18px;
  171. }
  172. .line span:nth-child(even){
  173. float:right;
  174. }
  175. .classification {
  176. width: 120px;
  177. border-right: 1px solid #f2f2f2;
  178. display: flex;
  179. flex-wrap: wrap;
  180. padding-top: 20px;
  181. }
  182. .classification p{
  183. width: 120px;
  184. text-align: center;
  185. line-height: 50px;
  186. margin: 0;
  187. cursor: pointer;
  188. }
  189. .classification p:hover {
  190. background: #dddddd;
  191. }
  192. .on {
  193. color: #409EFF;
  194. }
  195. .acl{
  196. display: inline-block;
  197. width: 300px;
  198. height: 22px;
  199. overflow: hidden;
  200. white-space: nowrap;
  201. text-overflow: ellipsis;
  202. display: flex;
  203. align-items: center;
  204. margin: 0;
  205. padding: 0;
  206. line-height: 0;
  207. }
  208. .cal {
  209. width: 300px;
  210. overflow: hidden;
  211. white-space: nowrap;
  212. text-overflow: ellipsis;
  213. cursor: pointer;
  214. }
  215. /* p {
  216. margin: 0 !important;
  217. } */
  218. </style>
  219. <script>
  220. import { error } from 'dingtalk-jsapi';
  221. import util from "../../common/js/util";
  222. export default {
  223. data() {
  224. return {
  225. searchField: '0',
  226. keyword:null,
  227. user: JSON.parse(sessionStorage.getItem("user")),
  228. userDetailVisible: false,
  229. userDetail:{},
  230. date: new Date(),
  231. users: [],
  232. participator:[],
  233. tableHeight: 0,
  234. listLoading: false,
  235. total: 0,
  236. page: 1,
  237. size: 20,
  238. list: [],
  239. subProjectVisible: false,
  240. subProjectList: [],//子项目列表
  241. currentProject:{},
  242. addSubProject: false,
  243. addFormVisible: false,
  244. addLoading: false,
  245. title: "",
  246. addForm: {
  247. name: '',
  248. userId: [],
  249. },
  250. rules: {
  251. name: [{ required: true, message: "请输入项目名称", trigger: "blur" }],
  252. },
  253. idx: 1,
  254. };
  255. },
  256. methods: {
  257. deleteSubPro(subProject) {
  258. this.$confirm("确定要删除子项目" + subProject.name + "吗?","删除子项目", {
  259. confirmButtonText: "确定",
  260. cancelButtonText: "取消",
  261. type: "warning"
  262. })
  263. .then(() => {
  264. this.listLoading = true;
  265. this.http.post('/sub-project/deleteProject',{
  266. id: subProject.id
  267. },
  268. res => {
  269. this.listLoading = false;
  270. if (res.code == "ok") {
  271. this.$message({
  272. message: "删除成功",
  273. type: "success"
  274. });
  275. this.subProject(this.currentProject);
  276. } else {
  277. this.$message({
  278. message: res.msg,
  279. type: "error"
  280. });
  281. }
  282. },
  283. error => {
  284. this.listLoading = false;
  285. this.$message({
  286. message: error,
  287. type: "error"
  288. });
  289. }
  290. );
  291. })
  292. .catch(() => {});
  293. },
  294. searchList() {
  295. this.page = 1;
  296. this.getList();
  297. },
  298. addNewSubProject(subProject) {
  299. if (subProject == null) {
  300. this.addForm = {projectId: this.currentProject.id}
  301. } else {
  302. this.addForm = subProject;
  303. }
  304. this.addSubProject = true;
  305. },
  306. //显示子项目
  307. subProject(item) {
  308. this.subProjectVisible = true;
  309. this.currentProject = item;
  310. this.http.post('/sub-project/list', {
  311. projectId: item.id
  312. },
  313. res => {
  314. if (res.code == "ok") {
  315. this.subProjectList = res.data;
  316. } else {
  317. this.$message({
  318. message: res.msg,
  319. type: "error"
  320. });
  321. }
  322. },
  323. error => {
  324. this.$message({
  325. message: error,
  326. type: "error"
  327. });
  328. });
  329. },
  330. //显示用户详情
  331. showUser(userId) {
  332. this.userDetailVisible = true;
  333. this.http.post(this.port.manage.userDetail, {
  334. userId: userId
  335. },
  336. res => {
  337. if (res.code == "ok") {
  338. this.userDetail = res.data;
  339. } else {
  340. this.$message({
  341. message: res.msg,
  342. type: "error"
  343. });
  344. }
  345. },
  346. error => {
  347. this.$message({
  348. message: error,
  349. type: "error"
  350. });
  351. });
  352. },
  353. //选择参与人
  354. changeParticipator() {
  355. //检查是否在参与人中,如果没有需要加入到参与人中
  356. console.log(this.addForm.userId);
  357. var find = false;
  358. this.participator = [];
  359. this.addForm.userId.forEach(u=>{
  360. var findUser = this.users.filter(au=>au.id == u)[0];
  361. this.participator.push(findUser);
  362. })
  363. },
  364. getUsers() {
  365. this.http.post(this.port.manage.list, {
  366. departmentId: -1,
  367. pageIndex: 1,
  368. pageSize: 99999
  369. },
  370. res => {
  371. if (res.code == "ok") {
  372. this.users = res.data.records;
  373. } else {
  374. this.$message({
  375. message: res.msg,
  376. type: "error"
  377. });
  378. }
  379. },
  380. error => {
  381. this.$message({
  382. message: error,
  383. type: "error"
  384. });
  385. });
  386. },
  387. //分页
  388. handleCurrentChange(val) {
  389. this.page = val;
  390. this.getList();
  391. },
  392. handleSizeChange(val) {
  393. this.size = val;
  394. this.getList();
  395. },
  396. //获取项目列表
  397. getList() {
  398. this.listLoading = true;
  399. this.http.post('/task/listByPage', {
  400. status: this.searchField,
  401. viewId: this.idx,
  402. pageIndex: this.page,
  403. pageSize: this.size,
  404. },
  405. res => {
  406. this.listLoading = false;
  407. if(res.code == 'ok') {
  408. this.list = res.data.records
  409. this.total = res.data.total
  410. } else {
  411. this.$message({
  412. message: res.msg,
  413. type: "error"
  414. });
  415. }
  416. console.log(res)
  417. },
  418. error => {
  419. this.listLoading = false;
  420. this.$message({
  421. message: error,
  422. type: "error"
  423. });
  424. })
  425. },
  426. //显示新增界面
  427. handleAdd(i, item) {
  428. if(i == -1) {
  429. this.title = "新增任务";
  430. this.addForm = {
  431. name: '',
  432. userId: [],
  433. code:'',
  434. inchargerId:null,
  435. }
  436. } else {
  437. this.title = "修改项目";
  438. var list = item.participator , arr = [];
  439. for(var j in list) {
  440. arr.push(list[j].id)
  441. }
  442. this.addForm = {
  443. id: item.id,
  444. name: item.projectName,
  445. userId: arr,
  446. code:item.projectCode,
  447. inchargerId: item.inchargerId
  448. }
  449. this.changeParticipator();
  450. }
  451. this.addFormVisible = true;
  452. },
  453. //提交子项目创建修改请求
  454. submitInsertSubProject () {
  455. this.$refs.form2.validate(valid => {
  456. if (valid) {
  457. this.http.post('/sub-project/saveOrUpdate',this.addForm,
  458. res => {
  459. if (res.code == "ok") {
  460. this.$message({
  461. message: "操作成功",
  462. type: "success"
  463. });
  464. this.subProject(this.currentProject);
  465. this.addSubProject = false;
  466. } else {
  467. this.$message({
  468. message: res.msg,
  469. type: "error"
  470. });
  471. }
  472. },
  473. error => {
  474. this.listLoading = false;
  475. this.$message({
  476. message: error,
  477. type: "error"
  478. });
  479. }
  480. );
  481. }
  482. });
  483. },
  484. submitInsert() {
  485. this.$refs.form1.validate(valid => {
  486. if (valid) {
  487. this.addLoading = true;
  488. let formData = new FormData();
  489. formData.append("name", this.addForm.name);
  490. if(this.addForm.id != null) {
  491. formData.append("id", this.addForm.id);
  492. }
  493. if(this.addForm.userId.length != 0) {
  494. for(var j in this.addForm.userId) {
  495. formData.append("userId", this.addForm.userId[j]);
  496. }
  497. }
  498. if(this.addForm.inchargerId != null) {
  499. formData.append("inchargerId", this.addForm.inchargerId);
  500. }
  501. if(this.addForm.code != null) {
  502. formData.append("code", this.addForm.code);
  503. }
  504. this.http.uploadFile(this.port.project.add,formData,
  505. res => {
  506. this.addLoading = false;
  507. if (res.code == "ok") {
  508. this.$message({
  509. message: this.addForm.id!=null?'修改':'创建'+"成功",
  510. type: "success"
  511. });
  512. this.addFormVisible = false;
  513. this.getList();
  514. } else {
  515. this.$message({
  516. message: res.msg,
  517. type: "error"
  518. });
  519. }
  520. },
  521. error => {
  522. this.addLoading = false;
  523. this.$message({
  524. message: error,
  525. type: "error"
  526. });
  527. });
  528. }
  529. });
  530. },
  531. // 删除
  532. deletePro(i, item) {
  533. this.$confirm("确定要项目" + item.projectName + "吗?","删除项目", {
  534. confirmButtonText: "确定",
  535. cancelButtonText: "取消",
  536. type: "warning"
  537. })
  538. .then(() => {
  539. this.listLoading = true;
  540. this.http.post(this.port.project.delete,{
  541. id: item.id
  542. },
  543. res => {
  544. this.listLoading = false;
  545. if (res.code == "ok") {
  546. this.$message({
  547. message: "删除成功",
  548. type: "success"
  549. });
  550. this.getList();
  551. } else {
  552. this.$message({
  553. message: res.msg,
  554. type: "error"
  555. });
  556. }
  557. },
  558. error => {
  559. this.listLoading = false;
  560. this.$message({
  561. message: error,
  562. type: "error"
  563. });
  564. }
  565. );
  566. })
  567. .catch(() => {});
  568. },
  569. detail(i) {
  570. this.$router.push("/list/" + this.list[i].id + "/" + this.list[i].projectName);
  571. },
  572. // 切换当前选项的索引
  573. switchs(e) {
  574. this.idx = e
  575. this.page = 1
  576. console.log(this.searchField)
  577. this.getList()
  578. },
  579. // 下拉框选择
  580. hiddens() {
  581. console.log(this.searchField)
  582. this.page = 1
  583. this.getList()
  584. },
  585. // 完成
  586. completes(e, el) {
  587. this.http.post('/task/finish', {
  588. id: e,
  589. taskStatus: el
  590. },
  591. res => {
  592. if (res.code == "ok") {
  593. this.$message({
  594. message: "提交成功",
  595. type: "success"
  596. });
  597. this.getList();
  598. } else {
  599. this.$message({
  600. message: res.msg,
  601. type: "error"
  602. });
  603. }
  604. },
  605. error => {
  606. this.listLoading = false;
  607. this.$message({
  608. message: error,
  609. type: "error"
  610. });
  611. }
  612. )
  613. },
  614. },
  615. created() {
  616. let height = window.innerHeight;
  617. this.tableHeight = height - 195;
  618. const that = this;
  619. window.onresize = function temp() {
  620. that.tableHeight = window.innerHeight - 195;
  621. };
  622. },
  623. mounted() {
  624. this.getList();
  625. this.getUsers();
  626. },
  627. };
  628. </script>
  629. <style lang="scss" scoped>
  630. // .classification {
  631. // width: 120px;
  632. // // height: 100%;
  633. // border-right: 1px solid #f2f2f2;
  634. // display: flex;
  635. // flex-wrap: wrap;
  636. // // align-items: center;
  637. // // justify-content: center;
  638. // padding-top: 20px;
  639. // }
  640. // .classification p{
  641. // width: 120px;
  642. // text-align: center;
  643. // line-height: 50px;
  644. // margin: 0;
  645. // cursor: pointer;
  646. // }
  647. // .classification p:hover {
  648. // background: #dddddd;
  649. // }
  650. // .on {
  651. // // background: #dddddd;
  652. // color: #409EFF;
  653. // }
  654. // .acl{
  655. // display: inline-block;
  656. // width: 300px;
  657. // height: 22px;
  658. // // line-height: 22px;
  659. // overflow: hidden;
  660. // white-space: nowrap;
  661. // text-overflow: ellipsis;
  662. // margin: 0;
  663. // padding: 0;
  664. // line-height: 0;
  665. // }
  666. // .cal {
  667. // width: 300px;
  668. // overflow: hidden;
  669. // white-space: nowrap;
  670. // text-overflow: ellipsis;
  671. // cursor: pointer;
  672. // }
  673. </style>