plan.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514
  1. <template>
  2. <div class="app-container">
  3. <div class="title-container">
  4. <breadcrumb id="breadcrumb-container" class="breadcrumb-container"/>
  5. </div>
  6. <y-detail-page-layout-back :edit-status="true" v-loading="vLoading" element-loading-text="处理中。。。" :list-query="listQuery">
  7. <div style="padding-top: 30px;">
  8. <el-tabs v-model="activeName">
  9. <el-tab-pane :label="itemName +'【排期】' " name="first" class="pane">
  10. <el-form ref="postForm" :model="postForm" class="form-container" style="padding-left: 100px">
  11. <div class="postInfo-container">
  12. <el-row>
  13. <el-col>
  14. <el-form-item
  15. label="阶段名称:"
  16. prop="name"
  17. label-width="180px"
  18. class="postInfo-container-item"
  19. >
  20. <el-input type="text" v-model="postForm.name" class="filter-item" />
  21. </el-form-item>
  22. </el-col>
  23. </el-row>
  24. <div class="postInfo-container">
  25. <el-row>
  26. <el-col>
  27. <el-form-item label="上个阶段:"
  28. prop="headerId"
  29. label-width="180px"
  30. class="postInfo-container-item">
  31. <el-select
  32. v-model="postForm.headerId"
  33. placeholder=""
  34. clearable
  35. filterable
  36. class="filter-item" :readonly="postForm.id" :disabled="postForm.id"
  37. >
  38. <el-option v-for="item in stages"
  39. :key="item.footerId"
  40. :label="item.name"
  41. :value="item.footerId" />
  42. </el-select>
  43. </el-form-item>
  44. </el-col>
  45. </el-row>
  46. </div>
  47. <div class="postInfo-container">
  48. <el-row>
  49. <el-col>
  50. <el-form-item
  51. label="阶段目标:"
  52. prop="target"
  53. label-width="180px"
  54. class="postInfo-container-item"
  55. >
  56. <el-input type="text" v-model="postForm.target" class="filter-item"/>
  57. </el-form-item>
  58. </el-col>
  59. </el-row>
  60. </div>
  61. </div>
  62. <div class="postInfo-container">
  63. <el-row>
  64. <el-col >
  65. <el-form-item
  66. label="开始日期:"
  67. prop="startDate"
  68. :rules="{required: true, message: '请选择日志日期', trigger: 'blur'}"
  69. label-width="180px"
  70. class="postInfo-container-item"
  71. >
  72. <el-date-picker
  73. v-model="postForm.startDate"
  74. type="date"
  75. value-format="yyyy-MM-dd"
  76. placeholder="选择日期"
  77. class="filter-item"
  78. style="width: 200px"
  79. />
  80. </el-form-item>
  81. </el-col>
  82. </el-row>
  83. </div>
  84. <div class="postInfo-container">
  85. <el-row>
  86. <el-col>
  87. <el-form-item
  88. label="结束日期:"
  89. prop="endDate"
  90. :rules="{required: true, message: '请选择日志日期', trigger: 'blur'}"
  91. label-width="180px"
  92. class="postInfo-container-item"
  93. >
  94. <el-date-picker
  95. v-model="postForm.endDate"
  96. type="date"
  97. value-format="yyyy-MM-dd"
  98. placeholder="选择日期"
  99. class="filter-item"
  100. style="width: 200px"
  101. />
  102. </el-form-item>
  103. </el-col>
  104. </el-row>
  105. </div>
  106. <div class="postInfo-container">
  107. <el-row>
  108. <el-col>
  109. <el-form-item label="负责人:"
  110. prop="endDate"
  111. label-width="180px"
  112. class="postInfo-container-item">
  113. <el-select
  114. v-model="postForm.dutyerId"
  115. placeholder=""
  116. clearable
  117. filterable
  118. class="filter-item"
  119. >
  120. <el-option
  121. v-for="item in users"
  122. :key="item.id"
  123. :label="item.name"
  124. :value="item.id"
  125. />
  126. </el-select>
  127. </el-form-item>
  128. </el-col>
  129. </el-row>
  130. </div>
  131. <div class="postInfo-container">
  132. <el-row>
  133. <el-col>
  134. <el-form-item
  135. label="阶段权重:"
  136. prop="weight"
  137. :rules="{required: true, message: '请填写阶段权重(0-100)', trigger: 'blur'}"
  138. label-width="180px"
  139. class="postInfo-container-item"
  140. >
  141. <el-input type="text" v-model="postForm.weight" class="filter-item" placeholder="计算参与人员提成">
  142. <i slot="suffix" style="font-size:normal;margin-right: 10px;line-height: 30px">%</i>
  143. </el-input>
  144. </el-form-item>
  145. </el-col>
  146. </el-row>
  147. </div>
  148. <div class="postInfo-container">
  149. <el-row>
  150. <el-col>
  151. <el-form-item
  152. label="逾期提成系数:"
  153. prop="coefficient"
  154. :rules="{required: true, message: '请填写逾期提成系数(0-100)', trigger: 'blur'}"
  155. label-width="180px"
  156. class="postInfo-container-item"
  157. >
  158. <el-input type="text" v-model="postForm.coefficient" class="filter-item" placeholder="计算参与人员提成">
  159. <i slot="suffix" style="font-size:normal;margin-right: 10px;line-height: 30px">%</i>
  160. </el-input>
  161. </el-form-item>
  162. </el-col>
  163. </el-row>
  164. </div>
  165. <div class="postInfo-container">
  166. <el-form-item
  167. label="参与人员:"
  168. prop="remark"
  169. label-width="180px"
  170. class="postInfo-container-item"
  171. >
  172. <el-button type="primary" icon="el-icon-edit" class="filter-item" @click="openJoiner" >设置</el-button>
  173. </el-form-item>
  174. <el-dialog
  175. width="600px"
  176. :title=" '['+title+']参与人员提成系数设置'"
  177. :visible.sync="dialogFormVisible"
  178. :close-on-click-modal="true"
  179. custom-class="customClass"
  180. >
  181. <el-alert
  182. title="打勾并设置提成系数有效,否则无效。"
  183. type="info"
  184. show-icon
  185. :closable="false">
  186. </el-alert>
  187. <y-page-list-layout :get-page-list="getJoinUsers" >
  188. <el-table
  189. slot="table"
  190. row-key="id"
  191. :data="joinUsers"
  192. ref="multipleTable"
  193. :header-row-style="{color: '#333333'}"
  194. @selection-change="handleSelectionChange"
  195. style="border-left: 1px solid #EBECED;border-right: 1px solid #EBECED;color: #333333;"
  196. >
  197. <el-table-column
  198. type="selection"
  199. width="55">
  200. </el-table-column>
  201. <el-table-column label="人员" width="100" align="center">
  202. <template slot-scope="{row}">
  203. <span>{{ row.userName }}</span>
  204. </template>
  205. </el-table-column>
  206. <el-table-column label="提成系数" align="center">
  207. <template slot-scope="{row}">
  208. <el-input v-model="row.weight" placeholder="请输入数字">
  209. <i slot="suffix" style="font-size:normal;margin-right: 10px;line-height: 30px">%</i>
  210. </el-input>
  211. </template>
  212. </el-table-column>
  213. </el-table>
  214. </y-page-list-layout>
  215. </el-dialog>
  216. </div>
  217. <div class="postInfo-container">
  218. <el-row>
  219. <el-col>
  220. <el-form-item
  221. label="备注信息:"
  222. prop="remark"
  223. label-width="180px"
  224. class="postInfo-container-item"
  225. >
  226. <el-input type="textarea" v-model="postForm.remark" class="filter-item" placeholder="200字符"/>
  227. </el-form-item>
  228. </el-col>
  229. </el-row>
  230. </div>
  231. <el-button type="success" id="addNode" @click="saveNode">保存</el-button>
  232. <el-button type="normal" @click="clean">清空</el-button>
  233. </el-form>
  234. <div class="nodeFlow">
  235. <div style="height: 300px;">
  236. <el-timeline v-if="stageFlow.length>0">
  237. <el-timeline-item v-for="(s,index) in stageFlow" :key="index" :timestamp="s.name" placement="top" color="green"
  238. @click.native="getDetail(s.id)">
  239. <el-card class="card">
  240. <div class="it">
  241. <icon class="el-icon-s-flag"/> <el-tag type="success">{{s.target}}</el-tag>
  242. </div>
  243. <div class="it">
  244. <icon class="el-icon-time"/> <el-tag>{{s.startDate}}</el-tag> 至 <el-tag>{{s.endDate}}</el-tag>
  245. </div>
  246. <div v-if="s.weight" class="it">
  247. <icon class="el-icon-coin"/> <el-tag type="danger">{{s.weight}}%</el-tag>
  248. </div>
  249. <div v-if="s.dutyer" class="it">
  250. <icon class="el-icon-user-solid"/> <el-tag>{{s.dutyer}}</el-tag>
  251. </div>
  252. <div v-if="s.participated" >
  253. <span v-for="(p,index) in s.participated" :key="index" class="it">
  254. <icon class="el-icon-user"/> <el-tag>{{p.userName}} : {{p.weight}}%</el-tag>
  255. </span>
  256. </div>
  257. <el-button class="del" type="danger" icon="el-icon-delete" @click="remove(s.id)"/>
  258. </el-card>
  259. </el-timeline-item>
  260. </el-timeline>
  261. </div>
  262. </div>
  263. </el-tab-pane>
  264. </el-tabs>
  265. </div>
  266. </y-detail-page-layout-back>
  267. </div>
  268. </template>
  269. <script>
  270. import Breadcrumb from '@/components/Breadcrumb'
  271. import YDetailPageLayoutBack from '@/components/YDetailPageLayout/back'
  272. export default {
  273. name: 'itemDetail',
  274. components: {
  275. Breadcrumb,
  276. YDetailPageLayoutBack
  277. },
  278. data() {
  279. return {
  280. type: 'detail',
  281. postForm: {
  282. itemId: this.$route.query.id,
  283. id:null,
  284. participators:[],
  285. name:null
  286. },
  287. itemId: this.$route.query.id,
  288. itemName: this.$route.query.itemName,
  289. id:null,
  290. activeName: 'first',
  291. vLoading: false,
  292. listQuery:null,
  293. filterMethod(query, item) {
  294. return item.label.indexOf(query) > -1;
  295. },
  296. stageFlow:[],
  297. stages:[],
  298. users: [],
  299. joinUsers: [],
  300. dialogFormVisible:false,
  301. selectedJoiners : [],
  302. title:null
  303. }
  304. },
  305. created() {
  306. this.listQuery = this.$route.query.listQuery;
  307. this.getFlow();
  308. this.getSimpleAll();
  309. this.$api.user.simpleAll().then(res => {
  310. this.users = res.data;
  311. });
  312. this.getJoinUsers();
  313. },
  314. methods: {
  315. toggleSelection(rows) {
  316. if (rows) {
  317. rows.forEach(row => {
  318. if (row.id!=null && row.weight!=null){
  319. this.$refs.multipleTable.toggleRowSelection(row, true);
  320. }
  321. });
  322. }
  323. },
  324. handleSelectionChange(val){
  325. this.postForm.participators = val;
  326. },
  327. openJoiner(){
  328. this.dialogFormVisible = true;
  329. this.title = " ";
  330. if (this.postForm.name!=null && this.postForm.name!=undefined){
  331. this.title = this.postForm.name;
  332. }
  333. setTimeout(() => {
  334. this.toggleSelection(this.joinUsers);
  335. }, 200)
  336. },
  337. getJoinUsers(){
  338. const that = this;
  339. that.$api.item.itemUser({itemId:this.itemId, stageId:this.id}).then(data => {
  340. if (data.code === 200) {
  341. this.joinUsers = data.data;
  342. } else {
  343. this.$message({
  344. type: 'error',
  345. message: data.msg
  346. })
  347. }
  348. })
  349. },
  350. getSimpleAll(){
  351. this.$api.itemStage.simpleAll(this.itemId).then(res => {
  352. this.stages = res.data;
  353. });
  354. },
  355. getFlow(){
  356. this.$api.itemStage.flow(this.itemId).then(res => {
  357. this.stageFlow = res.data===null?[]:res.data;
  358. });
  359. },
  360. getDetail(id) {
  361. if (id) {
  362. this.$api.itemStage.detail(id).then(res => {
  363. this.postForm = res.data;
  364. this.id = this.postForm.id;
  365. this.getJoinUsers();
  366. });
  367. }
  368. },
  369. remove(id){
  370. const that = this;
  371. that.$confirm('确认删除当前记录吗?', '警告', {
  372. confirmButtonText: '确认',
  373. cancelButtonText: '取消',
  374. type: 'warning'
  375. })
  376. .then(async () => {
  377. this.$api.itemStage.delete(id).then(res => {
  378. if (res.code === 200) {
  379. this.$notify({
  380. title: '成功',
  381. message: '删除成功',
  382. type: 'success',
  383. duration: 2000
  384. });
  385. this.getSimpleAll();
  386. this.getFlow();
  387. }
  388. })
  389. })
  390. .catch(err => { console.error(err) })
  391. },
  392. saveNode(){
  393. if (this.postForm.startDate>this.postForm.endDate){
  394. this.$notify({
  395. title: '错误',
  396. message: '开始日期不能大于结束日期',
  397. type: 'error',
  398. duration: 2000
  399. });
  400. return;
  401. }
  402. if (this.postForm.remark && this.postForm.remark.length>200){
  403. this.$notify({
  404. title: '错误',
  405. message: '备注信息不超过200字符',
  406. type: 'error',
  407. duration: 2000
  408. });
  409. return;
  410. }
  411. this.vLoading = true;
  412. this.$refs.postForm.validate(valid => {
  413. if (valid) {
  414. if (this.itemId && this.id===null) {
  415. this.$api.itemStage.add(Object.assign({}, this.postForm, {
  416. })).then(res => {
  417. if (res.code === 200) {
  418. this.$notify({
  419. title: '成功',
  420. message: '新增成功',
  421. type: 'success',
  422. duration: 2000
  423. });
  424. this.getSimpleAll();
  425. this.getFlow();
  426. this.vLoading = false
  427. }
  428. }).catch(() => {
  429. this.vLoading = false
  430. })
  431. }
  432. else {
  433. this.$api.itemStage.edit(Object.assign({}, this.postForm, {
  434. })).then(res => {
  435. if (res.code === 200) {
  436. this.$notify({
  437. title: '成功',
  438. message: '保存成功',
  439. type: 'success',
  440. duration: 2000
  441. });
  442. this.getSimpleAll();
  443. this.getFlow();
  444. this.vLoading = false
  445. }
  446. }).catch(() => {
  447. this.vLoading = false
  448. })
  449. }
  450. //清空表单
  451. this.clean();
  452. }
  453. })
  454. },
  455. clean(){
  456. this.postForm = {id:null};
  457. this.postForm.itemId = this.itemId;
  458. this.id = null;
  459. this.getJoinUsers();
  460. },
  461. },
  462. }
  463. </script>
  464. <style lang="css" scoped>
  465. .pane{
  466. display: flex;
  467. }
  468. .pane>div{
  469. flex: 1;
  470. }
  471. .form-container{
  472. padding-top: 30px;
  473. width: 700px;
  474. height: 800px;
  475. border: 1px solid darkgray;
  476. box-shadow: 10px 10px 5px #888888;;
  477. border-radius: 10px;
  478. }
  479. .form-container:hover{
  480. }
  481. .filter-item{
  482. width: 200px;
  483. }
  484. .nodeFlow{
  485. width: 300px;
  486. /*height: 800px;*/
  487. margin-left: 100px;
  488. overflow: auto;
  489. }
  490. #addNode{
  491. margin-left: 180px;
  492. }
  493. div.it{
  494. margin-top: 5px;
  495. }
  496. .card{
  497. cursor: pointer;
  498. display: flex;
  499. width: 500px;
  500. }
  501. .del{
  502. position: absolute;
  503. top:60px;
  504. left: 480px;
  505. }
  506. </style>
  507. <style lang="scss" scoped>
  508. /deep/.customClass{
  509. border-radius: 20px;
  510. }
  511. </style>