editask.vue 32 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751
  1. <template>
  2. <div class="editaskBox">
  3. <van-nav-bar :title="title" left-text="返回" @click-left="back" fixed left-arrow />
  4. <div class="content">
  5. <van-form>
  6. <div v-if="showOrNot">
  7. <van-cell title="所属项目" :value="select_project" @click="select_project_show = true,select_project_show_searchText = '',onSearchProject()"></van-cell>
  8. <van-popup v-model="select_project_show" position="bottom">
  9. <van-search v-model.trim="select_project_show_searchText" placeholder="输入项目名称搜索" @input="onSearchProject"></van-search>
  10. <div style="minHeight:300px;">
  11. <van-radio-group v-model="taskform.projectId">
  12. <div class="ewProjectlist">近期选择项目</div>
  13. <van-radio v-for="(uitem, index) in integrationProjectList" :key="index" :name="uitem" style="padding:10px">
  14. <span>{{uitem.projectName}}</span>
  15. </van-radio>
  16. </van-radio-group>
  17. <van-radio-group v-model="taskform.projectId">
  18. <div class="ewProjectlist">全部项目</div>
  19. <van-radio v-for="uitem in select_project_array" :key="uitem.id" :name="uitem" style="padding:10px">
  20. <span>{{uitem.projectName}}</span>
  21. </van-radio>
  22. </van-radio-group>
  23. <van-button style="width:100%;position: -webkit-sticky;position: sticky;bottom: 0;" @click="selectProject()">确定</van-button>
  24. </div>
  25. </van-popup>
  26. <van-cell title="所属任务分组" :value="select_grouping" @click="select_grouping_show = true"></van-cell>
  27. <van-popup v-model="select_grouping_show" position="bottom">
  28. <van-picker
  29. show-toolbar
  30. :columns="select_grouping_array"
  31. @confirm="selectGrouping"
  32. @cancel="select_grouping_show = false;$forceUpdate();">
  33. <template #option="item">
  34. {{item.name}}
  35. </template>
  36. </van-picker>
  37. </van-popup>
  38. <van-cell title="所属任务列表" :value="select_list" @click="select_list_show = true"></van-cell>
  39. <van-popup v-model="select_list_show" position="bottom">
  40. <van-picker
  41. show-toolbar
  42. :columns="select_list_array"
  43. @confirm="selectList"
  44. @cancel="select_list_show = false;$forceUpdate();">
  45. <template #option="item">
  46. {{item.stagesName}}
  47. </template>
  48. </van-picker>
  49. </van-popup>
  50. </div>
  51. <!-- 类型 -->
  52. <van-field v-model="taskform.taskType" label="类型" @click="taskType.show = true" readonly clickable>
  53. <template #input><span>{{taskType.list[taskform.taskType]}}</span></template>
  54. </van-field>
  55. <van-popup v-model="taskType.show" position="bottom" v-if="canEdit">
  56. <van-picker
  57. show-toolbar
  58. :columns="taskType.list"
  59. @confirm="tasktypeChange"
  60. @cancel="taskType.show = false;$forceUpdate();"/>
  61. </van-popup>
  62. <!-- 任务内容 -->
  63. <van-field v-model="taskform.name" label="任务内容" placeholder="请输入任务内容" :rules="[{ required: true, message: '请输入任务内容' }]" type="textarea" :disabled="!canEdit" :maxlength="40" show-word-limit></van-field>
  64. <!-- 开始时间 -->
  65. <van-field v-if="taskform.type != 1" v-model="taskform.startDate" label="开始时间" placeholder="请选择开始时间" @click="startDateShow = true" readonly clickable></van-field>
  66. <van-popup v-model="startDateShow" position="bottom" v-if="canEdit">
  67. <van-datetime-picker
  68. type="date"
  69. title="选择开始时间"
  70. v-model="currentDate1"
  71. @confirm="startDateChange"
  72. @cancel="startDateShow = false;$forceUpdate();"
  73. :min-date="minDate"
  74. :max-date="maxDate"/>
  75. </van-popup>
  76. <!-- 截止时间 -->
  77. <van-field v-model="taskform.endDate" label="截止时间" placeholder="请选择截止时间" @click="endDateShow = true" readonly clickable></van-field>
  78. <van-popup v-model="endDateShow" position="bottom" v-if="canEdit">
  79. <van-datetime-picker
  80. type="date"
  81. title="选择截止时间"
  82. v-model="currentDate2"
  83. @confirm="endDateChange"
  84. @cancel="endDateShow = false;$forceUpdate();"
  85. :min-date="minDate"
  86. :max-date="maxDate"/>
  87. </van-popup>
  88. <!-- 完成时间 -->
  89. <van-field v-if="taskform.type == 1" v-model="taskform.finishDate" label="完成时间" placeholder="请选择完成时间" @click="finishDateShow = true" readonly clickable></van-field>
  90. <van-popup v-model="finishDateShow" position="bottom" v-if="canEdit">
  91. <van-datetime-picker
  92. type="date"
  93. title="选择完成时间"
  94. v-model="currentDate3"
  95. @confirm="finishDateChange"
  96. @cancel="finishDateShow = false;$forceUpdate();"
  97. :min-date="minDate"
  98. :max-date="maxDate"/>
  99. </van-popup>
  100. <!-- 执行人 -->
  101. <div style="border: 0.5px solid #87c3ff;margin:0.2rem;position:relative" v-for="item,index in taskform.executorList" :key="index">
  102. <van-field v-model="item.executorName" :label="'执行人' + (index + 1)" placeholder="请选择执行人" @click="executorChange(item,index)" readonly clickable>
  103. <template #input>
  104. <span v-if="!item.executorName"></span>
  105. <span v-else-if="user.userNameNeedTranslate != 1">{{item.executorName}}</span>
  106. <span v-else><ww-open-data type='userName' :openid='item.executorName'></ww-open-data></span>
  107. </template>
  108. </van-field>
  109. <van-field label="计划工时">
  110. <template #input>
  111. <van-stepper v-model="item.planHours" :disabled="!canEdit"/><span>{{'\u3000h'}}</span>
  112. </template>
  113. </van-field>
  114. <van-icon v-if="index != 0 && canEdit" class="delete_executor" name="delete-o" @click.stop="deleteExecutor(index)" />
  115. <van-cell-group v-if="user.companyId == '3092'">
  116. <van-cell title="项目服务" :value="`${item.serviceName || ''} - ${item.serviceCode || ''}`" is-link @click="searchServiceCli(item,index)">
  117. <template #right-icon>
  118. <div class="iconBox">
  119. <!-- <van-icon name="close" size="18" class="iconRight" /> -->
  120. <!-- <van-icon name="arrow" size="18" class="iconRight" /> -->
  121. </div>
  122. </template>
  123. </van-cell>
  124. </van-cell-group>
  125. </div>
  126. <!-- 选择项目服务 -->
  127. <van-popup v-model="select_sapServiceList_show" position="bottom" style="height: 90%">
  128. <div class="popupDiv">
  129. <div class="popupSearch">
  130. <van-search v-model.trim="sapServiceVal" placeholder="搜索" @search="onSearchService" @clear="onSearchService" shape="round" background="#F4F4F4"></van-search>
  131. </div>
  132. <div class="popupCon conBorder">
  133. <van-radio-group v-model="sapServiceChange" class="popupItem marginNone borderNone">
  134. <van-radio v-for="uitem in sapServiceList" :key="uitem.id" :name="uitem" style="padding:10px">
  135. <span class="userNameClass_left">{{ uitem.serviceName }}</span>
  136. <span class="userNameClass_right">{{ uitem.serviceCode }}</span>
  137. </van-radio>
  138. </van-radio-group>
  139. </div>
  140. <div class="popupBtn">
  141. <van-button style="width:100%;background: #1989fa;color: #ffffff;position: -webkit-sticky;position: sticky;bottom: 0;" round @click="searchExecutorBtn()">确定</van-button>
  142. </div>
  143. </div>
  144. </van-popup>
  145. <van-popup v-model="executor.show" position="bottom" v-if="canEdit" style="height: 90%">
  146. <div class="popupDiv">
  147. <div class="popupSearch" v-if="user.userNameNeedTranslate != '1'">
  148. <van-search v-model="executor.searchText" placeholder="输入员工姓名搜索" @search="onSearch" shape="round" background="#F4F4F4"></van-search>
  149. </div>
  150. <div class="popupSearch" v-if="user.userNameNeedTranslate == '1'">
  151. <van-search v-model="executor.searchText" placeholder="输入员工姓名搜索" @search="getOnSearch(executor.searchText)" shape="round" background="#F4F4F4"></van-search>
  152. </div>
  153. <div class="popupCon conBorder">
  154. <van-radio-group v-model="executor.item" class="popupItem marginNone borderNone">
  155. <van-radio v-for="uitem in executor.searchList" :key="uitem.id" :name="uitem" style="padding:10px">
  156. <span v-if="user.userNameNeedTranslate != 1" class="userNameClass_left">{{uitem.name}}</span>
  157. <span v-else class="userNameClass_left"><ww-open-data type='userName' :openid='uitem.name'></ww-open-data></span>
  158. <span class="userNameClass_right">{{ uitem.jobNumber }}</span>
  159. </van-radio>
  160. </van-radio-group>
  161. </div>
  162. <div class="popupBtn">
  163. <van-button style="width:100%;background: #1989fa;color: #ffffff;position: -webkit-sticky;position: sticky;bottom: 0;" round @click="searchExecutor()">确定</van-button>
  164. </div>
  165. </div>
  166. </van-popup>
  167. <!-- 添加执行人 -->
  168. <div class="add_executor" @click="addExecutor" v-if="canEdit">添加执行人</div>
  169. <!-- 优先级 -->
  170. <van-field v-model="taskform.taskLevel" label="优先级" @click="taskLevel.show = true" readonly clickable>
  171. <template #input><span>{{taskLevel.list[taskform.taskLevel]}}</span></template>
  172. </van-field>
  173. <van-popup v-model="taskLevel.show" position="bottom" v-if="canEdit">
  174. <van-picker
  175. show-toolbar
  176. :columns="taskLevel.list"
  177. @confirm="taskLevelChange"
  178. @cancel="taskLevel.show = false;$forceUpdate();"/>
  179. </van-popup>
  180. <van-cell title="任务描述"/>
  181. <vue-html5-editor :content="taskform.taskDesc" :height="300" @change="htmleditor"></vue-html5-editor>
  182. </van-form>
  183. <div class="form_btn" style="position:fixed; bottom:0px;width:100%;z-index: 99">
  184. <div style="padding-bottom:10px;">
  185. <van-button square block type="info" loading-text="保存中..." @click="submitTask" native-type="submit" :loading="submitTaskBtn" style="width:100%;float:left;" :disabled="!canEdit">
  186. <div v-if="canEdit">保存</div>
  187. <div v-else>暂无权限编辑</div>
  188. </van-button>
  189. </div>
  190. </div>
  191. </div>
  192. </div>
  193. </template>
  194. <script>
  195. import { S } from 'core-js/modules/_export'
  196. export default {
  197. data() {
  198. return {
  199. showOrNot: false,
  200. title: '编辑任务',
  201. user: JSON.parse(localStorage.userInfo),
  202. taskId: JSON.parse(sessionStorage.taskId),
  203. currentDate1: new Date(),
  204. currentDate2: new Date(),
  205. currentDate3: new Date(),
  206. minDate: new Date(2020,0,1),
  207. maxDate: new Date(2025,11,31),
  208. canEdit: true,
  209. onSearchTime: null,
  210. taskform:{ // 表单
  211. taskType: 0,
  212. name: '',
  213. startDate: null,
  214. endDate: null,
  215. finishDate: null,
  216. taskLevel: 0,
  217. executorList: [{executorName: '',executorId: '',planHours: 8}],
  218. },
  219. taskType:{
  220. show: false,
  221. list: ['任务','里程碑','风险']
  222. },
  223. startDateShow: false,
  224. endDateShow: false,
  225. finishDateShow: false,
  226. submitTaskBtn: false,
  227. taskLevel:{
  228. show: false,
  229. list: ['一般','重要','紧急']
  230. },
  231. executor:{
  232. show: false,
  233. item: {id:null,name:''},
  234. index: 0,
  235. list: [],
  236. searchList: [],
  237. searchText: ''
  238. },
  239. select_project_show: false,
  240. select_grouping_show: false,
  241. select_list_show: false,
  242. select_project: '请选择',
  243. select_grouping: '请选择',
  244. select_list: '请选择',
  245. select_project_array: [],
  246. select_project_array_tow: [],
  247. select_grouping_array: [],
  248. select_list_array: [],
  249. select_project_show_searchText: '',
  250. integrationProjectList: [],
  251. sapServiceList:[], // 项目服务
  252. sapServiceListCoper:[], // 项目服务
  253. select_sapServiceList_show: false,
  254. sapServiceVal: '',
  255. sapServiceChange: {}
  256. }
  257. },
  258. mounted() {
  259. this.showOrNot = this.taskId.showOrNot
  260. this.getProjectList()
  261. if(!this.taskId.addNew){
  262. this.title = '编辑任务'
  263. this.getTask()
  264. }else{
  265. this.title = '新建任务'
  266. this.taskform = {
  267. projectId: '',
  268. groupId: '',
  269. stagesId: '',
  270. taskType: 0,
  271. name: '',
  272. startDate: null,
  273. endDate: null,
  274. finishDate: null,
  275. taskDesc: '',
  276. taskLevel: 0,
  277. executorList: [{executorName: '',executorId: '',planHours: this.user.timeType.allday}]
  278. }
  279. if(!this.taskId.showOrNot) {
  280. this.taskform.groupId = this.taskId.groupId
  281. this.taskform.stagesId = this.taskId.stagesId
  282. this.taskform.projectId = JSON.parse(sessionStorage.projectId)
  283. }
  284. }
  285. this.getUsersList()
  286. const { companyId } = this.user
  287. if(companyId == 3092) {
  288. this.getSapServiceList()
  289. }
  290. console.log('mounted',this.taskId,null);
  291. },
  292. methods: {
  293. selectProject(value,key) {
  294. this.select_project = this.taskform.projectId.projectName
  295. this.taskform.projectId = this.taskform.projectId.id
  296. console.log(this.taskform)
  297. this.getTaskGrouping()
  298. this.select_project_show_searchText = ''
  299. this.select_project_show = false
  300. this.select_list = ''
  301. this.select_grouping = ''
  302. this.taskform.groupId = ''
  303. this.taskform.stagesId = ''
  304. },
  305. selectGrouping(value){
  306. this.select_grouping = value.name
  307. this.taskform.groupId = value.id
  308. this.getStageList()
  309. this.select_grouping_show = false
  310. this.select_list = ''
  311. this.taskform.stagesId = ''
  312. },
  313. selectList(value) {
  314. console.log(value)
  315. this.select_list = value.stagesName
  316. this.taskform.stagesId = value.id
  317. this.select_list_show = false
  318. },
  319. onSearchProject() {
  320. let text = this.select_project_show_searchText
  321. if(text != '') {
  322. let projectArr = this.select_project_array_tow
  323. var arr = []
  324. for(var i in projectArr) {
  325. if(projectArr[i].projectName.indexOf(text) != '-1') {
  326. arr.push(projectArr[i])
  327. }
  328. }
  329. this.select_project_array = arr
  330. } else {
  331. this.select_project_array = this.select_project_array_tow
  332. }
  333. },
  334. getProjectList() {
  335. this.$axios.post("/project/getProjectList", {})
  336. .then(res => {
  337. if(res.code == "ok") {
  338. this.select_project_array = res.data
  339. this.select_project_array_tow = res.data
  340. this.getRecentlyProject()
  341. } else {
  342. this.$toast.fail('失败');
  343. }
  344. }).catch(err=> {this.$toast.clear();console.log(err)});
  345. },
  346. getRecentlyProject() {
  347. this.$axios.post('/project/nearProject',{})
  348. .then(res => {
  349. if(res.code == 'ok'){
  350. this.integrationProjectList = res.data
  351. }
  352. }).catch(err => {this.$toast.clear();this.cardRefLoading = false;})
  353. },
  354. getTaskGrouping() {
  355. this.$axios.post("/task-group/list", {projectId:this.taskform.projectId})
  356. .then(res => {
  357. if(res.code == "ok") {
  358. this.select_grouping_array = res.data
  359. } else {
  360. this.$toast.fail('失败');
  361. }
  362. }).catch(err=> {this.$toast.clear();console.log(err)});
  363. },
  364. getStageList() {
  365. this.$axios.post("/stages/list", {
  366. projectId: this.taskform.projectId,
  367. groupId: this.taskform.groupId,
  368. order: 'seq',
  369. isDesc: false
  370. })
  371. .then(res => {
  372. if(res.code == "ok") {
  373. this.select_list_array = res.data.list
  374. } else {
  375. this.$toast.fail('失败');
  376. }
  377. }).catch(err=> {this.$toast.clear();console.log(err)});
  378. },
  379. back() {
  380. history.back();
  381. },
  382. formatDate(date) {
  383. let mon = date.getMonth() + 1
  384. return `${date.getFullYear()}-${mon<10?'0'+mon:mon}-${date.getDate()<10?'0'+date.getDate():date.getDate()}`;
  385. },
  386. tasktypeChange(value,key){ // 类型
  387. this.taskform.taskType = key
  388. this.taskType.show = false
  389. },
  390. startDateChange(date){ // 开始时间
  391. this.taskform.startDate = this.formatDate(date)
  392. this.startDateShow = false
  393. },
  394. endDateChange(date){ // 截止时间
  395. this.taskform.endDate = this.formatDate(date)
  396. this.endDateShow = false
  397. },
  398. finishDateChange(date){ // 完成时间
  399. this.taskform.finishDate = this.formatDate(date)
  400. this.finishDateShow = false
  401. },
  402. executorChange(item,index){ // 选择执行人
  403. this.executor.searchText = ''
  404. this.getOnSearch('')
  405. this.executor.show = true
  406. this.executor.index = index
  407. this.executor.searchList.forEach(u=>{if (u.id == item.executorId) {
  408. this.executor.item = u
  409. }})
  410. },
  411. deleteExecutor(index){
  412. console.log('deleteExecutor');
  413. this.taskform.executorList.splice(index,1)
  414. this.$forceUpdate();
  415. },
  416. addExecutor(){
  417. console.log('addExecutor');
  418. this.taskform.executorList.push({
  419. executorName: '',
  420. executorId: '',
  421. planHours: this.user.timeType.allday
  422. })
  423. this.$forceUpdate();
  424. },
  425. onSearch(val) {
  426. if(this.user.userNameNeedTranslate != 1) {
  427. this.executor.searchList = [];
  428. this.executor.list.forEach(u=>{if (u.name.startsWith(val)) {
  429. this.executor.searchList.push(u);
  430. }})
  431. } else {
  432. if (this.onSearchTime != null) {
  433. clearTimeout(this.onSearchTime)
  434. }
  435. var that = this
  436. this.onSearchTime = setTimeout(() => {
  437. that.getOnSearch(val)
  438. }, 500)
  439. }
  440. },
  441. getOnSearch(val) {
  442. this.$axios.post("/user/getEmployeeList", {
  443. departmentId: -1,
  444. pageIndex: 1,
  445. pageSize: 200,
  446. keyword: val,
  447. status: 1,
  448. roleId: '',
  449. cursor: '',
  450. onlyDirect: 0,
  451. })
  452. .then(res => {
  453. if(res.code == "ok") {
  454. this.executor.searchList = res.data.records
  455. } else {
  456. this.$toast.fail('搜索失败');
  457. }
  458. }).catch(err=> {this.$toast.clear();console.log(err)});
  459. },
  460. searchExecutor(){
  461. this.taskform.executorList[this.executor.index].executorId = this.executor.item.id
  462. this.taskform.executorList[this.executor.index].executorName = this.executor.item.name
  463. this.executor.show = false
  464. console.log('searchExecutor',this.executor.item,this.executor.item.name);
  465. },
  466. taskLevelChange(value,key){ // 优先级
  467. this.taskform.taskLevel = key
  468. this.taskLevel.show = false
  469. },
  470. executorProjectJudgment(arr) {
  471. let arrList = JSON.parse(JSON.stringify(arr))
  472. // 将填写的数据以执行人id相同处理成二维数据
  473. const result = Object.values(arrList.reduce((acc, obj) => {
  474. const { executorId } = obj;
  475. if (!acc[executorId]) {
  476. acc[executorId] = [];
  477. }
  478. acc[executorId].push(obj);
  479. return acc;
  480. }, {}));
  481. console.log(result, '<== 去重后的数据')
  482. // 更具二维数据去判断项目服务是否相同
  483. for(var i in result) {
  484. const item = result[i]
  485. if(item.length > 1) {
  486. let size=new Set(item.map(item=>item.serviceId)).size
  487. if(size != item.length) {
  488. return false
  489. }
  490. }
  491. }
  492. return true
  493. },
  494. submitTask(){
  495. console.log('submitTask');
  496. const { companyId } = this.user
  497. if(!this.taskform.name.replace(/^\s*|\s*$/g,"")){
  498. return
  499. }
  500. // 执行人查重
  501. if(companyId != '3092') {
  502. let arr = this.taskform.executorList
  503. let json={};
  504. for(let i in arr){
  505. if(!json[arr[i].executorId]){
  506. json[arr[i].executorId]=1;
  507. }else{
  508. this.$toast.fail("执行人存在重复");
  509. return
  510. }
  511. }
  512. }
  513. // 针对依斯倍排除执行人相同和项目服务相同的任务
  514. if(companyId == '3092') {
  515. if(!this.executorProjectJudgment(this.taskform.executorList)) {
  516. this.$toast.fail("同一个项目服务执行人相同");
  517. return
  518. }
  519. }
  520. if(this.taskform.projectId == '' || this.taskform.projectId == null) {
  521. this.$toast.fail("请选择所属项目");
  522. return
  523. }
  524. if(this.taskform.groupId == '' || this.taskform.groupId == null) {
  525. this.$toast.fail("请选择所属任务分组");
  526. return
  527. }
  528. if(this.taskform.stagesId == '' || this.taskform.stagesId == null) {
  529. this.$toast.fail("请选择所属任务列表");
  530. return
  531. }
  532. // 去除未选择执行人的执行人列表
  533. this.taskform.executorList = this.taskform.executorList.filter(item => item.executorId)
  534. this.taskform.executorListStr = JSON.stringify(this.taskform.executorList)
  535. delete this.taskform.executorList
  536. delete this.taskform.subTaskList;
  537. delete this.taskform.refTaskList;
  538. delete this.taskform.progress;
  539. this.submitTaskBtn = true
  540. // return
  541. this.$axios.post("/task/save", this.taskform)
  542. .then(res => {
  543. this.submitTaskBtn = false
  544. if(res.code == "ok") {
  545. this.$toast.success('保存成功');
  546. this.back()
  547. } else {
  548. this.$toast.fail('保存失败');
  549. }
  550. }).catch(err=> {this.$toast.clear();console.log(err);this.submitTaskBtn = false});
  551. },
  552. htmleditor(e) {
  553. this.taskform.taskDesc = e
  554. console.log()
  555. },
  556. getTask(){
  557. this.$axios.post("/task/getTask", {
  558. id: this.taskId.id
  559. }).then(res => {
  560. if(res.code == "ok") {
  561. this.taskform = res.data
  562. this.taskform.createDate = null;
  563. this.taskform.indate = null;
  564. let projectManagement = false
  565. let authorityEditing = false
  566. if(!this.taskform.taskDesc){
  567. this.taskform.taskDesc = ''
  568. }
  569. if(this.taskform.startDate){
  570. this.currentDate1 = new Date(this.taskform.startDate)
  571. }
  572. if(this.taskform.endDate){
  573. this.currentDate2 = new Date(this.taskform.endDate)
  574. }
  575. if(this.taskform.finishDate){
  576. this.currentDate3 = new Date(this.taskform.finishDate)
  577. }
  578. // 判断编辑权限
  579. for(let i in this.user.functionList){
  580. if(this.user.functionList[i].name == '查看全部项目'){
  581. projectManagement = true
  582. }
  583. if(this.user.functionList[i].name == '编辑项目内任务') {
  584. authorityEditing = true
  585. }
  586. }
  587. if(authorityEditing || this.user.id == res.data.createrId || this.user.id == res.data.projectInchargerId || this.user.id == res.data.groupInchargerId || projectManagement || this.title == '新建任务'){
  588. this.canEdit = true
  589. }else{
  590. this.canEdit = false
  591. }
  592. // (
  593. // (
  594. // (addForm.executorListFront == null || addForm.executorListFront.length<10)
  595. // && (
  596. // addForm.id == null|| user.id == addForm.createrId || currentProject.inchargerId == user.id || permissions.projectManagement
  597. // )
  598. // )
  599. // || groupResponsibleId == user.id
  600. // )
  601. // this.canEdit = false
  602. } else {
  603. this.$toast.fail('获取失败');
  604. }
  605. }).catch(err=> {this.$toast.clear();console.log(err)});
  606. },
  607. getUsersList(){
  608. this.$axios.post("/user/getSimpleActiveUserList", {})
  609. .then(res => {
  610. if(res.code == "ok") {
  611. this.executor.list = res.data
  612. this.executor.searchList = res.data
  613. } else {
  614. this.$toast.fail('获取失败');
  615. }
  616. }).catch(err=> {this.$toast.clear();console.log(err)});
  617. },
  618. getSapServiceList() {
  619. this.$axios.post("/sap-project-service/sapServiceList", {})
  620. .then(res => {
  621. if(res.code == "ok") {
  622. this.sapServiceList = res.data
  623. this.sapServiceListCoper = JSON.parse(JSON.stringify(res.data))
  624. } else {
  625. this.$toast.fail('获取失败');
  626. }
  627. }).catch(err=> {this.$toast.clear();console.log(err)});
  628. },
  629. onSearchService() {
  630. if(!this.sapServiceVal) {
  631. this.sapServiceList = JSON.parse(JSON.stringify(this.sapServiceListCoper))
  632. return
  633. }
  634. let arr = JSON.parse(JSON.stringify(this.sapServiceListCoper.filter(item => item.serviceName.indexOf(this.sapServiceVal) != -1 || item.serviceCode.indexOf(this.sapServiceVal) != -1)))
  635. this.sapServiceList = arr
  636. },
  637. searchExecutorBtn() {
  638. console.log(this.sapServiceChange)
  639. const { serviceName, serviceCode, id } = this.sapServiceChange
  640. this.taskform.executorList[this.executor.index].serviceId = id
  641. this.taskform.executorList[this.executor.index].serviceName = `${serviceName}`
  642. this.taskform.executorList[this.executor.index].serviceCode = `${serviceCode}`
  643. this.select_sapServiceList_show = false
  644. console.log(this.taskform.executorList)
  645. },
  646. searchServiceCli(item,index) {
  647. const { companyId } = this.user
  648. this.executor.index = index
  649. this.sapServiceListCoper.forEach(u=>{if (u.id == item.serviceId) {
  650. console.log(u)
  651. this.sapServiceChange = {
  652. serviceName: u.serviceName,
  653. serviceCode: u.serviceCode,
  654. id: u.id,
  655. companyId
  656. }
  657. }})
  658. console.log(this.sapServiceChange, item)
  659. this.select_sapServiceList_show = true
  660. }
  661. },
  662. }
  663. </script>
  664. <style lang="less" scoped>
  665. .content{
  666. margin-top: 46px;
  667. overflow: auto;
  668. .add_executor{
  669. font-size:13px;
  670. color:#1989fa;
  671. padding-left:0.42667rem;
  672. padding-bottom:.2rem;
  673. width:100px
  674. }
  675. .delete_executor{
  676. position: absolute;
  677. top: 3px;
  678. right: 3px;
  679. font-size: 22px;
  680. color: #c03131;
  681. }
  682. }
  683. .xinmingghao {
  684. overflow: hidden;
  685. text-overflow: ellipsis;
  686. width: 200px;
  687. display: inline-block;
  688. float: right;
  689. }
  690. .iconBox {
  691. position: relative;
  692. top: 2px;
  693. }
  694. .iconRight {
  695. margin-left: 10px;
  696. }
  697. .ewProjectlist {
  698. padding: 10px 10px 10px 20px;
  699. border-bottom: 1px solid #666;
  700. color: #a5a5a5;
  701. }
  702. </style>
  703. <style>
  704. .editaskBox .van-radio__label {
  705. width: 100%;
  706. display: inline-block;
  707. }
  708. </style>