createTask.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658
  1. <template>
  2. <view>
  3. <l-file ref="lFile" @up-success="onSuccess"></l-file>
  4. <!-- 顶部 -->
  5. <cu-custom bgColor="bg-blue" :isBack="true">
  6. <block slot="backText">新建自定义任务</block>
  7. <block slot="content"></block>
  8. <block slot="right">
  9. <view class=" flex justify-center">
  10. <button @click="save()" class="cu-btn round line-blue text-white" style="width: 160rpx;height: 66rpx;padding: 0;">提交</button>
  11. </view>
  12. </block>
  13. </cu-custom>
  14. <!-- 内容 -->
  15. <form>
  16. <view class="cu-form-group_1">
  17. <view class="title">任务名称</view>
  18. <input placeholder="请输入任务名称" placeholder-style="color:#AEAEAE;font-size:30rpx" v-model="data.taskName" name="input"></input>
  19. </view>
  20. <view class="cu-form-group_2">
  21. <view class="title">任务说明</view>
  22. <textarea maxlength="-1" placeholder="请输入" placeholder-style="color:#AEAEAE;font-size:30rpx" v-model="data.content"></textarea>
  23. </view>
  24. <view class="cu-form-group_3 flex">
  25. <view class="title">每人限定时间</view>
  26. <picker class="flex-sub text-right" @change="timeLimitChange" :value="data.timeLimit" :range="timeLimitList">
  27. <view class="picker">
  28. {{timeLimitList[data.timeLimit]}}天
  29. <text class='cuIcon-right text-gray'></text>
  30. </view>
  31. </picker>
  32. </view>
  33. <view class="cu-form-group_3 flex">
  34. <view class="title">任务流程</view>
  35. <picker class="flex-sub text-right" @change="flowChange" :value="data.flow" :range="workflow" range-key="name">
  36. <view class="picker">
  37. {{flowName}}
  38. <text class='cuIcon-right text-gray'></text>
  39. </view>
  40. </picker>
  41. </view>
  42. <!-- <view class="cu-form-group_3">
  43. <view class="title">任务状态</view>
  44. <picker @change="taskStatusChange" :value="taskIndex" :range="taskStatus">
  45. <view class="picker">
  46. {{taskStatus[taskIndex]}}
  47. <text class='cuIcon-right text-gray'></text>
  48. </view>
  49. </picker>
  50. </view> -->
  51. <!-- <view class="cu-form-group_3" v-if="pickerData.length!=0">
  52. <view class="title">预警规则</view>
  53. <picker @change="PickerChange" :value="index" :range="pickerData">
  54. <view class="picker">
  55. {{pickerData[index]}}
  56. <text class='cuIcon-right text-gray'></text>
  57. </view>
  58. </picker>
  59. </view> -->
  60. <!-- <view class="cu-form-group_3">
  61. <view class="title">开始日期</view>
  62. <datetime-picker v-model="data.startTime" placeholder="请选择开始日期" style="color:#AEAEAE;font-size:30rpx" fields="minute"
  63. @change="changeStartTime"></datetime-picker>
  64. <text class='cuIcon-right text-gray'></text>
  65. </view> -->
  66. <!-- <view class="cu-form-group_3">
  67. <view class="title">结束日期</view>
  68. <datetime-picker v-model="data.endTime" placeholder="请选择结束日期" style="color:#AEAEAE;font-size:30rpx" fields="minute"
  69. @change="changeEndTime"></datetime-picker>
  70. <text class='cuIcon-right text-gray'></text>
  71. </view> -->
  72. </form>
  73. <!-- 负责人内容 -->
  74. <view class="cu-form-group_1">
  75. <view class="title">任务人</view>
  76. </view>
  77. <view class="cu-list_b">
  78. <view class="cu-list_1">
  79. <view class="cu-list_item" v-for="item in principal" :key="item.id">
  80. <view class="cu-capsule round">
  81. <!-- <view v-if="item.type==1" class='cu-tag bg-gray-secondary '>
  82. 施工方
  83. </view>
  84. <view v-if="item.type==2" class='cu-tag bg-gray-secondary '>
  85. 监理方
  86. </view>
  87. <view v-if="item.type==3" class='cu-tag bg-gray-secondary '>
  88. 业主方
  89. </view>
  90. <view class="cu-tag bg-gray-secondary">
  91. <text class="cuIcon-titles text-gray"></text>
  92. </view> -->
  93. <view class="cu-tag bg-gray-secondary" :class="{ 'padding-sm': data.flow != 0 }">
  94. {{item.user_name}}
  95. </view>
  96. <view v-if="data.flow == 0" class="cu-tag bg-gray-secondary" @tap="delprincipal(item,'task')">
  97. <image src="/static/index/delete-blue.png" class="login-img"></image>
  98. </view>
  99. </view>
  100. </view>
  101. </view>
  102. <view v-if="data.flow == 0">
  103. <button @click="addPrincipal('task')" class="cu-btn round bg-blue-secondary"><text class="cuIcon-add text-blue">新增</text></button>
  104. </view>
  105. </view>
  106. <view class="cu-form-group_1">
  107. <view class="title">抄送人</view>
  108. </view>
  109. <view class="cu-list_b">
  110. <view class="cu-list_1">
  111. <view class="cu-list_item" v-for="(item) in copyList" :key="item.id">
  112. <view class="cu-capsule round">
  113. <!-- <view v-if="item.type==1" class='cu-tag bg-gray-secondary '>
  114. 施工方
  115. </view>
  116. <view v-if="item.type==2" class='cu-tag bg-gray-secondary '>
  117. 监理方
  118. </view>
  119. <view v-if="item.type==3" class='cu-tag bg-gray-secondary '>
  120. 业主方
  121. </view>
  122. <view class="cu-tag bg-gray-secondary">
  123. <text class="cuIcon-titles text-gray"></text>
  124. </view> -->
  125. <view class="cu-tag bg-gray-secondary">
  126. {{item.user_name}}
  127. </view>
  128. <view class="cu-tag bg-gray-secondary" @tap="delprincipal(item,'copy')">
  129. <image src="/static/index/delete-blue.png" class="login-img"></image>
  130. </view>
  131. </view>
  132. </view>
  133. </view>
  134. <view>
  135. <button @click="addPrincipal('copy')" class="cu-btn round bg-blue-secondary"><text class="cuIcon-add text-blue">新增</text></button>
  136. </view>
  137. </view>
  138. <!-- 上传附件-->
  139. <view class="cu-form-group_3">
  140. <view class="title">上传附件</view>
  141. <view class="action">
  142. <button @click="chooseFile()" class="cu-btn round line-blue"><text class="cuIcon-add text-blue">新增</text></button>
  143. </view>
  144. </view>
  145. <view class="cu-list menu-avatar">
  146. <view class="cu-item" v-for="(item,index) in uploadFileList" :key="index">
  147. <view class="cu-avatar round lg">
  148. <image v-if="item.type==1" :src="fileImage[0]" class="menuImageTask"></image>
  149. <image v-if="item.type==2" :src="fileImage[1]" class="menuImageTask"></image>
  150. <image v-if="item.type==3" :src="fileImage[2]" class="menuImageTask"></image>
  151. <image v-if="item.type==4" :src="fileImage[3]" class="menuImageTask"></image>
  152. </view>
  153. <view class="content text-cut">
  154. <view class="text-black text-cut text-lg">{{item.name}}</view>
  155. <view class="flex justify-start">
  156. <text class="text-gray text-sm">{{item.size}}</text>
  157. </view>
  158. </view>
  159. <view class="action" style="width: auto;">
  160. <view class=" text-gray text-sm margin-right-sm" @click="delFile(index)">
  161. <image src="/static/index/delete-blue.png" class="login-img"></image>
  162. </view>
  163. </view>
  164. </view>
  165. </view>
  166. <!-- 弹窗 已不用-->
  167. <view class="cu-modal bottom-modal " :class="modalShow?'show':''">
  168. <view class="cu-dialog">
  169. <!-- 内容 -->
  170. <view class="boderbo margin-bottom-xxxl ">
  171. <!-- 菜单-->
  172. <view class="padding bg-white text-black">
  173. <text>目前只支持上传以下类型的文件 </text>
  174. </view>
  175. <view class="cu-list grid bg-black col-4 no-border">
  176. <view class="cu-item text-black" v-for="(item,index) in menuList" :key="index">
  177. <view>
  178. <image class="menuImageTask" :src="item.image"></image>
  179. </view>
  180. <text>{{item.name}}</text>
  181. </view>
  182. </view>
  183. </view>
  184. </view>
  185. </view>
  186. </view>
  187. </template>
  188. <script>
  189. import config from "../../../core/api.js"
  190. export default {
  191. data() {
  192. return {
  193. modalShow: false,
  194. principal: [],
  195. fileImage: ["/static/task/excel.png", "/static/task/word.png", "/static/task/pdf.png", "/static/task/image.png", ],
  196. menuList: [{
  197. name: "XLS",
  198. image: "/static/task/excel.png"
  199. },
  200. {
  201. name: "DOC",
  202. image: "/static/task/word.png"
  203. },
  204. {
  205. name: "PDF",
  206. image: "/static/task/pdf.png"
  207. },
  208. {
  209. name: "JPG",
  210. image: "/static/task/image.png"
  211. },
  212. ],
  213. userInfo: "",
  214. rulesData: [],
  215. pickerData: [],
  216. index: 0,
  217. uploadFileList: [],
  218. taskStatus: ['未完成', '完成'],
  219. taskIndex: 0,
  220. data: {
  221. taskName: "",
  222. content: "",
  223. status: 0,
  224. rules: "",
  225. startTime: "",
  226. endTime: "",
  227. principal: "",
  228. userId: uni.getStorageSync("userInfo").id,
  229. file: '',
  230. contractId: '',
  231. timeLimit:0,//限定时间
  232. flow:0,//任务流程
  233. },
  234. timeLimitList:[1,2,3,4,5,6,7,10,15,20,25,30],
  235. workflow:[{id:0,name:"自定义流程"}],
  236. flowName:'自定义流程',
  237. copyList:[],
  238. contractId : uni.getStorageSync("porject"+"_"+uni.getStorageSync("userInfo").id).contractId,
  239. projectId : uni.getStorageSync("porject"+"_"+uni.getStorageSync("userInfo").id).id,
  240. }
  241. },
  242. onLoad() {
  243. this.userInfo = uni.getStorageSync("userInfo");
  244. this.data.contractId = this.contractId;
  245. //console.log(this.data.contractId)
  246. //this.findRule();
  247. this.findWorkflow();
  248. },
  249. onShow() {
  250. uni.$on("taskPerson", res => {
  251. this.principal = res;
  252. //console.log(this.principal)
  253. })
  254. uni.$on("copyPerson", res => {
  255. this.copyList = res;
  256. //console.log(this.principal)
  257. })
  258. },
  259. onBackPress() {/* 监听返回事件,删除上传的文件 */
  260. /* var that =this;
  261. that.uploadFileList.forEach(item=>{
  262. that.delOssFile(item.path)
  263. }) */
  264. },
  265. methods: {
  266. delprincipal(value,type) {
  267. let list = []
  268. if(type == 'task'){
  269. list = this.principal;
  270. }else if(type == 'copy'){
  271. list = this.copyList;
  272. }
  273. list.forEach((item, index, arry) => {
  274. if (item.id == value.id) {
  275. list.splice(index, 1);
  276. return;
  277. }
  278. })
  279. },
  280. delFile(value) {
  281. let data = [];
  282. var that = this;
  283. that.uploadFileList.forEach((item, index, arry) => {
  284. if (value != index) { //把没有删除的留下来
  285. data.push(item)
  286. } else { //删除云端文件
  287. that.delOssFile(item.path);
  288. }
  289. })
  290. that.uploadFileList = data;
  291. },
  292. //删除云端文件
  293. delOssFile(delData) {
  294. this.http.request("/app/task/delOssFile", {
  295. name: delData
  296. })
  297. },
  298. addPrincipal(type) {
  299. //console.log(this.principal);
  300. let list = [];
  301. let name = '';
  302. if(type == 'task'){
  303. list = this.principal;
  304. name = '选择任务人'
  305. }else if(type == 'copy'){
  306. list = this.copyList;
  307. name = '选择抄送人'
  308. }
  309. //把已选值储存到全局变量
  310. getApp().globalData.principal = list;
  311. uni.navigateTo({
  312. url: "/pages/constructionLog/personnel/personnel?name=" + name
  313. })
  314. },
  315. /**
  316. * 选择日期时间
  317. * @param {Object} date 日期数据
  318. */
  319. changeStartTime(date) {
  320. this.data.startTime = date.fmt1 + " " + date.fmt8;
  321. console.log(this.startTime)
  322. },
  323. /**
  324. * 选择日期时间
  325. * @param {Object} date 日期数据
  326. */
  327. changeEndTime(date) {
  328. this.data.endTime = date.fmt1 + " " + date.fmt8;
  329. },
  330. stopPenetrate() {
  331. return;
  332. },
  333. colseFlie() {
  334. this.modalShow = false;
  335. },
  336. /* 获取预警规则、根据合同同id和用户id */
  337. findRule() {
  338. var that = this;
  339. var contractId = this.contractId;
  340. var useId = that.userInfo.id;
  341. that.http.request("/app/task/findRule", {
  342. userId: useId,
  343. contractId: contractId
  344. }).then((res) => {
  345. if (res.datas != null) {
  346. res.datas.forEach((item) => {
  347. that.pickerData.push(item.rulesName)
  348. })
  349. that.rulesData = res.datas;
  350. that.data.rules = that.rulesData[0].id;
  351. }
  352. })
  353. },
  354. PickerChange(e) {
  355. this.index = e.detail.value;
  356. //选中的内容
  357. this.rulesData.forEach((item, index) => {
  358. if (index == this.index) {
  359. this.data.rules = item.id;
  360. }
  361. })
  362. },
  363. taskStatusChange(e) {
  364. this.taskIndex = e.detail.value;
  365. this.taskStatus.forEach((item, index) => {
  366. if (index == this.taskIndex) {
  367. this.data.status = this.taskIndex;
  368. }
  369. })
  370. },
  371. onSuccess(res) {
  372. var that = this;
  373. console.log(res.data.id);
  374. if (res.data.id == "null") {
  375. that.$prompt.none("上传的文件格式不正确")
  376. } else {
  377. console.log('上传成功回调:');
  378. console.log(res);
  379. that.uploadFileList.push(JSON.parse(res.data.id));
  380. }
  381. /* that.modalShow=false; */
  382. },
  383. //选择文件
  384. chooseFile() {
  385. var that = this;
  386. //that.modalShow=true;
  387. var url = config.api;
  388. var token = uni.getStorageSync("token");
  389. this.$refs.lFile.upload({
  390. // #ifdef APP-PLUS
  391. currentWebview: this.$mp.page.$getAppWebview(),
  392. url: url + '/app/task/saveTaskFile',
  393. header: {
  394. "Authorization": token
  395. },
  396. name: "file",
  397. // #endif
  398. });
  399. },
  400. // /* 提交 */
  401. // save() {
  402. // var that = this;
  403. // if (that.data.taskName == "") {
  404. // that.$prompt.none("请填写任务名称");
  405. // return
  406. // }
  407. // that.http.request("/app/task/taskRename", {
  408. // userId: that.data.userId,
  409. // contractId: that.data.contractId,
  410. // taskName: that.data.taskName
  411. // }).then((res) => {
  412. // if (res.result != '-1') {
  413. // that.$prompt.none("任务名称已存在");
  414. // } else {
  415. // if (that.data.content == "") {
  416. // that.$prompt.none("请填写任务说明");
  417. // return
  418. // }
  419. // if (that.data.startTime == "") {
  420. // that.$prompt.none("请选择开始日期");
  421. // return
  422. // }
  423. // if (that.data.endTime == "") {
  424. // that.$prompt.none("请选择结束日期");
  425. // return
  426. // }
  427. // if (that.principal.length == 0) {
  428. // that.$prompt.none("请选择负责人");
  429. // return
  430. // }
  431. // //获取负责人,利用逗号隔开多个人员
  432. // that.principal.forEach((item) => {
  433. // that.data.principal += item.id + ",";
  434. // })
  435. // //获取上传的文件
  436. // var file;
  437. // if (that.uploadFileList.length > 0) {
  438. // that.data.file = JSON.stringify(that.uploadFileList);
  439. // }
  440. // that.http.request("/app/task/saveTask", that.data).then((res) => {
  441. // if (res.result == "1") {
  442. // that.$prompt.none("提交成功");
  443. // //清除全局变量
  444. // getApp().globalData.principal = [];
  445. // setTimeout(function() {
  446. // uni.navigateBack({
  447. // delta: 1
  448. // })
  449. // }, 300)
  450. // } else {
  451. // that.$prompt.none("提交失败");
  452. // }
  453. // })
  454. // }
  455. // })
  456. // },
  457. /* 提交 */
  458. save() {
  459. var that = this;
  460. if (that.data.taskName == "") {
  461. that.$prompt.none("请填写任务名称");
  462. return
  463. }
  464. that.http.request("/app/task/taskRename", {
  465. userId: that.data.userId,
  466. contractId: that.data.contractId,
  467. taskName: that.data.taskName
  468. }).then((res) => {
  469. if (res.result != '-1') {
  470. that.$prompt.none("任务名称已存在");
  471. } else {
  472. if (that.data.content == "") {
  473. that.$prompt.none("请填写任务说明");
  474. return
  475. }
  476. if (that.principal.length == 0) {
  477. that.$prompt.none("请选择任务人");
  478. return
  479. }
  480. var copyUserIds = [];
  481. this.copyList.forEach((item)=>{
  482. copyUserIds.push(item.id)
  483. })
  484. //获取负责人,利用逗号隔开多个人员
  485. that.principal.forEach((item) => {
  486. that.data.principal += item.id + ",";
  487. })
  488. //获取上传的文件
  489. var file;
  490. if (that.uploadFileList.length > 0) {
  491. that.data.file = JSON.stringify(that.uploadFileList);
  492. }
  493. that.http.request("/app/task/saveTask", {
  494. userId:this.data.userId,
  495. contractId:that.data.contractId,
  496. status:that.data.status,
  497. taskName:that.data.taskName,
  498. content:that.data.content,
  499. projectId:this.projectId,
  500. taskFlow:this.data.flow,
  501. principal:that.data.principal,
  502. blackout_days:this.timeLimitList[this.data.timeLimit],
  503. file:that.data.file,
  504. copyUserIds:copyUserIds.join(','),
  505. }).then((res) => {
  506. if (res.result == "1") {
  507. that.$prompt.none("提交成功");
  508. //清除全局变量
  509. getApp().globalData.principal = [];
  510. setTimeout(function() {
  511. uni.navigateBack({
  512. delta: 1
  513. })
  514. }, 300)
  515. } else {
  516. that.$prompt.none("提交失败");
  517. }
  518. })
  519. }
  520. })
  521. },
  522. timeLimitChange(e){
  523. this.data.timeLimit = e.detail.value;
  524. },
  525. flowChange(e){
  526. //console.log(e.detail)
  527. this.flowName = this.workflow[e.detail.value].name;
  528. this.data.flow = this.workflow[e.detail.value].id;
  529. if(this.data.flow != 0){
  530. this.http.request("/app/getLinks",{id:this.data.flow}).then((res)=>{
  531. //console.log(res)
  532. if(res.datas && res.datas.length > 0){
  533. res.datas.forEach((item)=>{
  534. item.user_name = item.userName
  535. })
  536. this.principal = res.datas;
  537. }
  538. })
  539. }else{
  540. this.principal = [];
  541. }
  542. },
  543. /**
  544. * 查询填报流程
  545. */
  546. findWorkflow(){
  547. this.http.request("/app/workflowlist",{type:'1',contractId:this.contractId}).then((res)=>{
  548. res.datas.forEach((item)=>{
  549. this.workflow.push(item);
  550. });
  551. this.workflow.forEach((item,index)=>{
  552. item.value =''+index+'';
  553. })
  554. })
  555. }
  556. }
  557. }
  558. </script>
  559. <style>
  560. .cu-list.grid>.cu-item uni-text {
  561. display: block;
  562. margin-top: 4px;
  563. color: #101010;
  564. font-size: 14px;
  565. line-height: 17px;
  566. }
  567. .boderbo {
  568. border-bottom: 1px solid #F7F7F7;
  569. }
  570. .cu-form-group_1 {
  571. display: flex;
  572. align-items: center;
  573. padding: 0 24rpx;
  574. border-bottom: 2rpx solid #E3E1E1;
  575. height: 88rpx;
  576. background-color: #fff;
  577. }
  578. .cu-form-group_1 .title {
  579. width: 142rpx;
  580. font-size: 30rpx;
  581. color: #101010;
  582. }
  583. .cu-form-group_1 input {
  584. width: 560rpx;
  585. color: #8a8a8a;
  586. font-size: 30rpx;
  587. }
  588. .cu-form-group_2 {
  589. display: flex;
  590. padding: 22rpx 24rpx;
  591. background-color: #fff;
  592. margin-bottom: 22rpx;
  593. }
  594. .cu-form-group_2 .title {
  595. width: 142rpx;
  596. font-size: 30rpx;
  597. color: #101010;
  598. }
  599. .cu-form-group_2 textarea {
  600. font-size: 30rpx;
  601. color: #8a8a8a;
  602. width: 560rpx;
  603. height: 130rpx;
  604. }
  605. .cu-form-group_3 {
  606. display: flex;
  607. align-items: center;
  608. justify-content: space-between;
  609. padding: 0 24rpx;
  610. border-bottom: 2rpx solid #E3E1E1;
  611. height: 88rpx;
  612. background-color: #fff;
  613. }
  614. .cu-form-group_3:last-child {
  615. border-bottom: none;
  616. margin-bottom: 22rpx;
  617. }
  618. .cu-form-group_3 .title {
  619. font-size: 30rpx;
  620. color: #101010;
  621. }
  622. .cu-form-group_3 .picker {
  623. color: #8a8a8a;
  624. font-size: 30rpx;
  625. }
  626. .cu-list_b{background-color: #fff;padding: 22rpx 24rpx;margin-bottom: 22rpx;}
  627. .cu-list_1{display: flex;flex-wrap: wrap;}
  628. .cu-list_item{margin-bottom: 26rpx;margin-right: 20rpx;}
  629. </style>