editask.vue 32 KB

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