taskEdit.vue 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601
  1. <template>
  2. <div class="detail">
  3. <mt-header class="detail_head" fixed title="编辑任务">
  4. <router-link to="" slot="left">
  5. <mt-button icon="back" v-on:click.native='jumpBack()'></mt-button>
  6. </router-link>
  7. </mt-header>
  8. <div class="detail_body">
  9. <div class="detailBox">
  10. <mt-field label="任务名称" placeholder="请输入任务名称" v-model="taskForm.name"></mt-field>
  11. <mt-field label="任务编码" placeholder="请输入任务编码" v-model="taskForm.code"></mt-field>
  12. <mt-field label="计划时间" placeholder="请选择计划时间" type="date" v-model="taskForm.planTime"></mt-field>
  13. <mt-field label="工作量" placeholder="请输入工作量" type="number" v-model="taskForm.workLoad">天</mt-field>
  14. <mt-field label="接收人" id="recUser" placeholder="请选择接收人" v-on:click.native="chooseRec()" disableClear disabled v-model="taskForm.recipientName"></mt-field>
  15. <mt-field label="参与人" id="parUser" placeholder="请选择参与人" v-on:click.native="choosePar()" disableClear disabled v-model="taskForm.participantsNames"></mt-field>
  16. <mt-field label="任务内容" placeholder="请输入任务内容" type="textarea" rows="4" v-model="taskForm.content" class="taskContent"></mt-field>
  17. </div>
  18. <div class="detailBox">
  19. <mt-field label="付款方" placeholder="请输入付款方" v-model="taskForm.payer"></mt-field>
  20. <mt-field label="收款方" placeholder="请输入收款方" v-model="taskForm.payee"></mt-field>
  21. <mt-field label="费用" placeholder="请输入费用" type="number" v-model="taskForm.fee">元</mt-field>
  22. </div>
  23. <div class="detailBox">
  24. <div class="left_tag">所属分类</div>
  25. <div class="right">
  26. <ul class="address_first">
  27. <li v-for="(item,index) in labels" :id="'btn'+item.id" v-bind:class="{'active':item.id==taskForm.tagId}" v-on:click="chooseTag(item.id)">
  28. {{item.name}}
  29. <img v-if="index > 4" v-on:click="delTag(item.id)" src="../../assets/image/del.png">
  30. </li>
  31. <li v-on:click="addNewTag()" class="add">+</li>
  32. </ul>
  33. </div>
  34. </div>
  35. <div class="btn">
  36. <mt-button class="allBtn" size="large" type="primary" v-on:click.native="submit()">确定</mt-button>
  37. <mt-button class="allBtn" size="large" v-on:click.native="jumpBack()">取消</mt-button>
  38. </div>
  39. </div>
  40. <mt-popup v-model="popupVisible" position="right" class="allocation">
  41. <mt-header class="detail_head" fixed title="选择参与人">
  42. <router-link to="" slot="left">
  43. <mt-button icon="back" v-on:click="toPrev()"></mt-button>
  44. </router-link>
  45. </mt-header>
  46. <div class="detailBox">
  47. <mt-checklist title="checkbox list" v-model="ids" :options="uselist" @change="checkon"></mt-checklist>
  48. </div>
  49. </mt-popup>
  50. </div>
  51. </template>
  52. <script>
  53. import { MessageBox } from 'mint-ui';
  54. export default {
  55. data() {
  56. return {
  57. id: this.$route.params.id,
  58. user: JSON.parse(sessionStorage.getItem("user")),
  59. detail: '',
  60. taskForm: {
  61. id: this.$route.params.id,
  62. publishId: JSON.parse(sessionStorage.getItem("user")).id,
  63. name: '',
  64. code: '',
  65. planTime: '',
  66. workLoad: '',
  67. recipientName: '',
  68. recipientId: '',
  69. participantsNames: '',
  70. participantsIds: '',
  71. content: '',
  72. payer: '',
  73. payee: '',
  74. fee: '',
  75. tagId: 0,
  76. },
  77. labels: [],
  78. users: [],
  79. uselist: [],
  80. popupVisible: false,
  81. ids: [],
  82. canClick: true,
  83. }
  84. },
  85. methods: {
  86. getDetail() {
  87. this.$indicator.open();
  88. this.http.post(this.port.task.detail, {
  89. 'id': this.id
  90. } ,
  91. res => {
  92. this.$indicator.close();
  93. if (res.code == "ok") {
  94. this.detail = res.data;
  95. var participantsIds = '',
  96. participantsNames = '';
  97. for(var i in res.data.participantsVOS) {
  98. participantsIds += res.data.participantsVOS[i].userId + ',';
  99. participantsNames += res.data.participantsVOS[i].userName + ',';
  100. this.ids.push(res.data.participantsVOS[i].userId)
  101. }
  102. participantsIds = participantsIds.substring(0,participantsIds.length-1);
  103. participantsNames = participantsNames.substring(0,participantsNames.length-1)
  104. this.taskForm = {
  105. id: this.$route.params.id,
  106. publishId: JSON.parse(sessionStorage.getItem("user")).id,
  107. name: res.data.name,
  108. code: res.data.code,
  109. planTime: res.data.planTime,
  110. workLoad: res.data.workLoad,
  111. recipientName: res.data.recipientName,
  112. recipientId: res.data.recipientId,
  113. participantsNames: participantsNames,
  114. participantsIds: participantsIds,
  115. content: res.data.content,
  116. payer: res.data.payer,
  117. payee: res.data.payee,
  118. fee: res.data.fee,
  119. tagId: res.data.tagId,
  120. }
  121. this.getLabels();
  122. } else {
  123. this.$toast({
  124. message: res.msg,
  125. duration: 2000
  126. });
  127. }
  128. }, error => {
  129. this.$indicator.close();
  130. this.$toast({
  131. message: error,
  132. duration: 2000
  133. });
  134. })
  135. },
  136. // 标签列表
  137. getLabels() {
  138. this.http.post(this.port.task.label, {} ,
  139. res => {
  140. if (res.code == "ok") {
  141. this.labels = res.data;
  142. } else {
  143. this.$toast({
  144. message: res.msg,
  145. duration: 2000
  146. });
  147. }
  148. }, error => {
  149. this.$toast({
  150. message: error,
  151. duration: 2000
  152. });
  153. })
  154. },
  155. addNewTag() {
  156. MessageBox({
  157. $type:'prompt',
  158. title:'',
  159. message:'请输入任务类型名称',
  160. closeOnClickModal:false,
  161. showCancelButton:true,
  162. inputValidator:function(v){
  163. if (v === null) {
  164.    return true;
  165. }
  166. if (v != ""){
  167. return true
  168. } else {
  169. return false
  170. }
  171. },
  172. inputErrorMessage:'请输入任务类型名称',
  173. showInput:true
  174. }).then(({ value, action }) => {
  175. if(value == null) {
  176. this.$toast({
  177. message: '创建失败',
  178. duration: 2000
  179. });
  180. return false;
  181. } else {
  182. this.$indicator.open();
  183. this.http.post(this.port.task.addLabel, {
  184. 'name': value,
  185. } ,
  186. res => {
  187. this.$indicator.close();
  188. if (res.code == "ok") {
  189. this.getLabels();
  190. } else {
  191. this.$toast({
  192. message: res.msg,
  193. duration: 2000
  194. });
  195. }
  196. }, error => {
  197. this.$indicator.close();
  198. this.$toast({
  199. message: error,
  200. duration: 2000
  201. });
  202. })
  203. }
  204. }).catch(() => {
  205. });
  206. },
  207. chooseTag(id) {
  208. $("#btn"+id).addClass("active").siblings().removeClass("active");
  209. this.taskForm.tagId = id;
  210. },
  211. delTag(id) {
  212. MessageBox.confirm('', { 
  213. message: '是否删除该分类?', 
  214. title: '', 
  215. confirmButtonText: '确定', 
  216. cancelButtonText: '取消' 
  217.  }).then(action => { 
  218. if (action == 'confirm') {     //确认的回调
  219. this.http.post(this.port.task.delLabel, {
  220. 'id': id
  221. } ,
  222. res => {
  223. if (res.code == "ok") {
  224. this.$toast({
  225. message: "删除成功",
  226. duration: 2000
  227. });
  228. this.getLabels();
  229. } else {
  230. this.$toast({
  231. message: res.msg,
  232. duration: 2000
  233. });
  234. }
  235. }, error => {
  236. this.$toast({
  237. message: error,
  238. duration: 2000
  239. });
  240. })
  241. }
  242.  }).catch(err => { 
  243.  });
  244. },
  245. // 人员列表
  246. getUserList() {
  247. this.http.post(this.port.user.list, {} ,
  248. res => {
  249. if (res.code == "ok") {
  250. for(var i in res.data) {
  251. // if(res.data[i].departmentGuid == this.user.deptId) {
  252. var list = res.data[i].userVOS;
  253. for(var j in list) {
  254. if(list[j].id != this.user.id) {
  255. this.users.push({
  256. id: list[j].id,
  257. name: list[j].name,
  258. })
  259. }
  260. }
  261. // }
  262. }
  263. } else {
  264. this.$toast({
  265. message: res.msg,
  266. duration: 2000
  267. });
  268. }
  269. }, error => {
  270. this.$toast({
  271. message: error,
  272. duration: 2000
  273. });
  274. })
  275. },
  276. chooseRec() {
  277. var _this = this;
  278. var dataShippingSpace = this.users;
  279. var pickerDiv = document.getElementById("recUser");
  280. var pickerView = new PickerView({
  281. bindElem: pickerDiv,
  282. data: dataShippingSpace,
  283. title: "负责人",
  284. leftText: "取消",
  285. rightText: "确定",
  286. rightFn: function(selectArr) {
  287. _this.taskForm.recipientId = selectArr[0].id;
  288. _this.taskForm.recipientName = selectArr[0].name;
  289. }
  290. });
  291. },
  292. choosePar() {
  293. this.uselist = [];
  294. for(var i in this.users) {
  295. this.uselist.push({
  296. label: this.users[i].name,
  297. value: this.users[i].id,
  298. })
  299. }
  300. this.popupVisible = true;
  301. },
  302. checkon() {
  303. this.taskForm.participantsIds = "";
  304. this.taskForm.participantsNames = "";
  305. for(var i in this.ids) {
  306. for(var j in this.uselist) {
  307. if(this.ids[i] == this.uselist[j].value) {
  308. this.taskForm.participantsIds += this.uselist[j].value + ',';
  309. this.taskForm.participantsNames += this.uselist[j].label + ',';
  310. break;
  311. }
  312. }
  313. }
  314. this.taskForm.participantsIds = this.taskForm.participantsIds.substring(0,this.taskForm.participantsIds.length-1);
  315. this.taskForm.participantsNames = this.taskForm.participantsNames.substring(0,this.taskForm.participantsNames.length-1)
  316. },
  317. toPrev() {
  318. this.popupVisible = false;
  319. },
  320. // 创建
  321. submit() {
  322. if(this.canClick) {
  323. this.canClick = false;
  324. if(this.taskForm.name == null || this.taskForm.name == "") {
  325. this.$toast({
  326. message: '请输入任务名称',
  327. duration: 2000
  328. });
  329. this.canClick = true;
  330. return false;
  331. } else if(this.taskForm.code == null || this.taskForm.code == "") {
  332. this.$toast({
  333. message: '请输入任务编码',
  334. duration: 2000
  335. });
  336. this.canClick = true;
  337. return false;
  338. } else if(this.taskForm.planTime == null || this.taskForm.planTime == "") {
  339. this.$toast({
  340. message: '请选择计划时间',
  341. duration: 2000
  342. });
  343. this.canClick = true;
  344. return false;
  345. } else if(this.taskForm.workLoad == null || this.taskForm.workLoad == "") {
  346. this.$toast({
  347. message: '请输入工作量',
  348. duration: 2000
  349. });
  350. this.canClick = true;
  351. return false;
  352. } else if(this.taskForm.content == null || this.taskForm.content == "") {
  353. this.$toast({
  354. message: '请输入工作内容',
  355. duration: 2000
  356. });
  357. this.canClick = true;
  358. return false;
  359. } else {
  360. this.$indicator.open();
  361. var _this = this ,
  362. form = {
  363. id: this.taskForm.id,
  364. publishId: this.user.id,
  365. name: this.taskForm.name,
  366. code: this.taskForm.code,
  367. planTime: this.taskForm.planTime,
  368. workLoad: this.taskForm.workLoad,
  369. content: this.taskForm.content,
  370. tagId: this.taskForm.tagId
  371. };
  372. if(this.taskForm.recipientId != '') {
  373. form.recipientId = this.taskForm.recipientId
  374. }
  375. if(this.taskForm.participantsIds != '') {
  376. form.participantsIdes = this.taskForm.participantsIds
  377. }
  378. if(this.taskForm.payer != '') {
  379. form.payer = this.taskForm.payer
  380. }
  381. if(this.taskForm.payee != '') {
  382. form.payee = this.taskForm.payee
  383. }
  384. if(this.taskForm.fee != '') {
  385. form.fee = this.taskForm.fee
  386. }
  387. this.http.post( this.port.task.add, form,
  388. res => {
  389. this.$indicator.close();
  390. if (res.code == "ok") {
  391. this.$toast({
  392. message: '修改成功',
  393. duration: 2000
  394. });
  395. setTimeout(function(){
  396. _this.$router.go(-1);
  397. }, 1000);
  398. } else {
  399. this.canClick = true;
  400. this.$toast({
  401. message: res.msg,
  402. duration: 2000
  403. });
  404. }
  405. },
  406. error => {
  407. this.canClick = true;
  408. this.$indicator.close();
  409. this.$toast({
  410. message: error,
  411. duration: 2000
  412. });
  413. });
  414. }
  415. } else {
  416. this.$toast({
  417. message: '请勿重复提交',
  418. duration: 2000
  419. });
  420. }
  421. },
  422. jumpBack() {
  423. this.$router.go(-1);
  424. }
  425. },
  426. created() {
  427. this.getUserList();
  428. this.getDetail();
  429. },
  430. mounted() {
  431. }
  432. }
  433. </script>
  434. <style scoped>
  435. .detail_head {
  436. background: #fff;
  437. color: #333;
  438. height: 0.4rem;
  439. }
  440. .detail_body {
  441. margin-top: 0.4rem;
  442. padding-bottom: 0.15rem;
  443. }
  444. .detail {
  445. background: #EFEFEF;
  446. }
  447. .detailBox {
  448. background: #fff;
  449. margin-bottom: 0.11rem;
  450. }
  451. .left{
  452. float:left;
  453. /* margin: 0.15rem; */
  454. padding: 0.15rem 0 0.1rem 0;
  455. }
  456. .left_tag {
  457. padding: 0.15rem 0.15rem 0.1rem 0.15rem;
  458. }
  459. .right div{
  460. line-height: 0.21rem;
  461. white-space: nowrap;
  462. overflow: hidden;
  463. text-overflow: ellipsis;
  464. }
  465. .btn {
  466. width: 80%;
  467. margin: 0.2rem auto 0;
  468. }
  469. .allocation {
  470. width: 100%;
  471. height: 100%;
  472. }
  473. .allocation .detailBox {
  474. margin-top: 0.12rem;
  475. }
  476. .address_first .current{
  477. background:#eee;
  478. color: #6f83ff;
  479. border-left: 2px solid #6f83ff;
  480. }
  481. .right > ul {
  482. margin: 0;
  483. padding: 0;
  484. overflow: auto;
  485. -webkit-transition-duration: 0.4s;
  486. box-sizing:border-box;
  487. padding: 0.08rem 0.1rem;
  488. }
  489. .right > ul > li {
  490. display: inline-block;
  491. height: 0.2rem;
  492. line-height: 0.22rem;
  493. font-size: 0.14rem;
  494. color: #ccc;
  495. padding: 0.02rem 0.12rem;
  496. margin: 0.06rem 0.07rem;
  497. border: 1px solid #ccc;
  498. border-radius: 50px;
  499. min-width: 0.3rem;
  500. text-align: center;
  501. position: relative;
  502. }
  503. .right > ul > li img {
  504. position: absolute;
  505. top: -0.05rem;
  506. right: -0.08rem;
  507. width: 0.18rem;
  508. height: 0.18rem;
  509. }
  510. .right > ul > li.add {
  511. border: 1px solid #777;
  512. color: #777;
  513. }
  514. .right > ul > li.active {
  515. border: 1px solid #2680EB;
  516. color: #2680EB;
  517. }
  518. .right div img.pic {
  519. width: 0.8rem;
  520. height: 0.8rem;
  521. margin: 0.15rem 0 0 0.3rem ;
  522. }
  523. .textColor {
  524. margin-top: 0.4rem;
  525. color: #8e8e8e;
  526. padding: 0.12rem;
  527. font-size: 0.12rem;
  528. }
  529. .example {
  530. color: #8e8e8e;
  531. padding: 0.02rem 0.12rem;
  532. font-size: 0.12rem;
  533. }
  534. .allBtn {
  535. width: 80%;
  536. margin: 0.18rem auto;
  537. }
  538. </style>
  539. <style>
  540. .detail_head .mint-header-title {
  541. font-weight: 600;
  542. font-size: 0.15rem;
  543. }
  544. .detail_head .mint-button-text {
  545. color: #26a2ff;
  546. }
  547. .detailBox .mint-cell {
  548. padding: 0 0 0 0.02rem;
  549. }
  550. .mint-popup.allocation {
  551. background: #efefef;
  552. }
  553. .mint-msgbox {
  554. width: 70%;
  555. }
  556. .mint-cell-wrapper {
  557. background-image: none;
  558. }
  559. </style>