Year.vue 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233
  1. <style lang="scss" scoped>
  2. .year{
  3. display: flex;
  4. height: 100%;
  5. }
  6. .tool-panel{
  7. width: 250px;
  8. padding: 15px;
  9. background-color: #F8F9FB;
  10. *{
  11. width: 100%;
  12. margin: 5px 0;
  13. }
  14. }
  15. table{
  16. flex: auto;
  17. thead{
  18. color: #909399;
  19. font-weight: 500;
  20. }
  21. tr{
  22. background-color: #FFF;
  23. }
  24. th,td{
  25. padding: 12px 0;
  26. padding-left: 10px;
  27. padding-right: 10px;
  28. text-overflow: ellipsis;
  29. vertical-align: middle;
  30. border-bottom: 1px solid #EBEEF5;
  31. a{
  32. cursor: pointer;
  33. }
  34. }
  35. }
  36. .search-part{
  37. padding: 5px 15px;
  38. .add-user{
  39. float: right;
  40. }
  41. }
  42. .dialog-style{
  43. div{
  44. text-align: center;
  45. margin: 5px;
  46. label{
  47. display: inline-block;
  48. width: 100px;
  49. text-align: right;
  50. }
  51. .el-textarea,.el-input{
  52. display: inline-block;
  53. width: 400px;
  54. }
  55. .text-label{
  56. vertical-align: top;
  57. margin-top: 10px;
  58. }
  59. }
  60. }
  61. .center-text{
  62. text-align: center;
  63. }
  64. </style>
  65. <template>
  66. <div class="year">
  67. <div class="tool-panel">
  68. <el-button type="primary" @click="visibleChange = true;noEdit = false;plan = {};">新增年度计划</el-button>
  69. </div>
  70. <table>
  71. <thead>
  72. <tr>
  73. <th>计划名</th>
  74. <!-- <th>部门</th> -->
  75. <!-- <th>参与成员</th> -->
  76. <th>年份</th>
  77. <th>内容</th>
  78. <th style="width:120px;text-align: center;">操作</th>
  79. </tr>
  80. </thead>
  81. <tbody>
  82. <tr v-for="(item,index) in planeList" :key="index">
  83. <td>{{item.name}}</td>
  84. <!-- <td>{{item.depart}}</td> -->
  85. <!-- <td>{{item.member}}</td> -->
  86. <td>{{item.year}}</td>
  87. <td>{{item.content}}</td>
  88. <td>
  89. <a @click="changeData(item,true)">详情</a>
  90. &nbsp;&nbsp;
  91. <a @click="changeData(item)">修改</a>
  92. &nbsp;&nbsp;
  93. <a @click="judgePlan(item)">评价</a>
  94. &nbsp;&nbsp;
  95. <a @click="visibleDelete = true;plan.id = item.id">删除</a>
  96. </td>
  97. </tr>
  98. </tbody>
  99. </table>
  100. <el-dialog
  101. class="dialog-style"
  102. :title="noEdit?'详情':'编辑'"
  103. :visible.sync="visibleChange"
  104. width="600px">
  105. <div>
  106. <label>名称:</label>
  107. <el-input name="name" v-model="plan.name" placeholder="请输入名称" required="required" :disabled="noEdit"></el-input>
  108. </div>
  109. <div>
  110. <label>年份:</label>
  111. <el-date-picker
  112. v-model="yearData"
  113. type="year"
  114. :disabled="noEdit"
  115. placeholder="选择年">
  116. </el-date-picker>
  117. </div>
  118. <div>
  119. <label class="text-label">内容:</label>
  120. <el-input v-model="plan.content" placeholder="请输入内容" required="required" type="textarea" :autosize="{ minRows: 5}" :disabled="noEdit"></el-input>
  121. </div>
  122. <span slot="footer" class="dialog-footer">
  123. <el-button type="primary" @click="visibleChange = false;plan={}" v-if="!noEdit">取消</el-button>
  124. <el-button type="primary" @click="change" v-if="!noEdit">确 定</el-button>
  125. </span>
  126. </el-dialog>
  127. <el-dialog
  128. :title="plan.name + ' 任务评价'"
  129. :visible.sync="visibleJudge"
  130. width="800px">
  131. <div v-html="plan.evaluation" v-show="noEdit"></div>
  132. <Judge :planJudge="plan.evaluation" :changeSignal="changeSignal" @setEvaluation="setEvaluation" v-show="!noEdit"></Judge>
  133. <span slot="footer" class="dialog-footer">
  134. <el-button type="primary" @click="noEdit = false;" v-if="noEdit">编辑</el-button>
  135. <el-button type="primary" @click="visibleJudge = false;plan={}" v-if="!noEdit">取消</el-button>
  136. <el-button type="primary" @click="change" v-if="!noEdit">确 定</el-button>
  137. </span>
  138. </el-dialog>
  139. <el-dialog
  140. title="提示"
  141. :visible.sync="visibleDelete"
  142. width="200px">
  143. <p class="center-text">确认删除?</p>
  144. <span slot="footer" class="dialog-footer">
  145. <el-button @click="visibleDelete = false;plan={}">取 消</el-button>
  146. <el-button type="primary" @click="deletePlan">确 定</el-button>
  147. </span>
  148. </el-dialog>
  149. </div>
  150. </template>
  151. <script>
  152. import { getPlanList,addPlan,updatePlan,deletePlan } from '@/api/year';
  153. import Judge from "@/components/MainPage/Judge/Judge";
  154. export default {
  155. name: 'Year',
  156. components:{
  157. Judge
  158. },
  159. data () {
  160. return {
  161. params:{
  162. userId: this.$store.state.checkUser.id
  163. },
  164. planeList:[],
  165. plan:{},
  166. yearData:'',
  167. noEdit: false,
  168. visibleChange: false,
  169. visibleDelete: false,
  170. visibleJudge: false,
  171. changeSignal: false
  172. }
  173. },
  174. created() {
  175. this.getPlanList();
  176. },
  177. methods: {
  178. getPlanList(){
  179. getPlanList().then((data) => {
  180. this.planeList = data.data;
  181. })
  182. },
  183. deletePlan(){
  184. deletePlan(this.plan).then((result) => {
  185. this.$message(result?'删除成功':'删除失败');
  186. this.visibleDelete = false;
  187. this.plan = {};
  188. this.getPlanList();
  189. })
  190. },
  191. changeData(item,flag){
  192. this.visibleChange = true;
  193. this.noEdit = flag;
  194. this.plan = JSON.parse(JSON.stringify( item ));
  195. this.yearData = new Date(item.year,1,1);
  196. },
  197. change(){
  198. this.plan.year = this.yearData.getFullYear();
  199. if(this.plan.id){
  200. updatePlan(this.plan).then((result) => {
  201. this.$message(result.result?'更新成功':'更新失败');
  202. this.visibleChange = false;
  203. this.visibleJudge = false;
  204. this.plan = {};
  205. this.getPlanList();
  206. this.$store.dispatch('setCurPlanSin');
  207. })
  208. }
  209. else{
  210. addPlan(this.plan).then((result) => {
  211. this.$message(result.result?'添加成功':'添加失败');
  212. this.visibleChange = false;
  213. this.plan = {};
  214. this.getPlanList();
  215. this.$store.dispatch('setCurPlanSin');
  216. })
  217. }
  218. },
  219. setEvaluation(val){
  220. this.plan.evaluation = val;
  221. },
  222. judgePlan(item){
  223. this.visibleJudge = true;
  224. this.noEdit = true;
  225. this.plan = JSON.parse(JSON.stringify( item ));
  226. this.changeSignal = !this.changeSignal;
  227. this.yearData = new Date(item.year,1,1);
  228. }
  229. }
  230. }
  231. </script>