List.vue 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  1. <template>
  2. <div style="width: 100%">
  3. <div>
  4. <el-button type="primary" v-if="!isShowCheckbox" size="small" @click="showCheckbox">批量操作</el-button>
  5. <span v-if="isShowCheckbox">
  6. <el-button type="info" size="small" @click="isShowCheckbox=false">取消操作</el-button>
  7. <el-button type="danger" size="small" @click="handleMultipleDelete">批量删除</el-button>
  8. <el-select
  9. @change="handleMultipleStatusChange"
  10. v-model="status"
  11. size='medium'
  12. placeholder="批量修改状态"
  13. style="margin-left: 30px">
  14. <el-option
  15. v-for="item in statusOptions"
  16. :key="item.value"
  17. :label="item.label"
  18. :value="item.value">
  19. </el-option>
  20. </el-select>
  21. <el-select
  22. @change="handleMultipleAssignmentChange"
  23. v-model="assignment"
  24. size='medium'
  25. placeholder="批量修改负责人"
  26. style="margin-left: 30px">
  27. <el-option
  28. v-for="item in assignmentOptions"
  29. :key="item.value"
  30. :label="item.label"
  31. :value="item.value">
  32. </el-option>
  33. </el-select>
  34. </span>
  35. </div>
  36. <el-table
  37. :data="listData"
  38. @selection-change="handleSelectionChange"
  39. style="width: 100%">
  40. <el-table-column
  41. v-if="isShowCheckbox"
  42. type="selection"
  43. width="60">
  44. </el-table-column>
  45. <el-table-column
  46. prop="projectCode"
  47. label="编号"
  48. width="180">
  49. </el-table-column>
  50. <el-table-column
  51. prop="title"
  52. min-width="180"
  53. label="标题">
  54. </el-table-column>
  55. <el-table-column
  56. prop="assignment"
  57. label="优先级"
  58. width="180">
  59. </el-table-column>
  60. <el-table-column
  61. prop="status"
  62. label="状态"
  63. width="180">
  64. </el-table-column>
  65. <el-table-column
  66. prop="assignment"
  67. label="计划时间"
  68. width="180">
  69. </el-table-column>
  70. <el-table-column
  71. prop="assignment"
  72. label="创建时间"
  73. width="180">
  74. </el-table-column>
  75. <el-table-column
  76. prop="assignment"
  77. label="经办人"
  78. width="180">
  79. </el-table-column>
  80. </el-table>
  81. <el-pagination
  82. style="display: flex;flex-direction: row;justify-content: center;margin-top: 20px"
  83. background
  84. @current-change="handleCurrentChange"
  85. :page-size="pageSize"
  86. layout="prev, pager, next"
  87. :total="total">
  88. </el-pagination>
  89. </div>
  90. </template>
  91. <script>
  92. export default {
  93. name: 'List',
  94. props: {
  95. listData: Array,
  96. total: Number,
  97. statusOptions: {
  98. type: Array,
  99. default() {
  100. return [
  101. {
  102. label: '未分配',
  103. value: 1,
  104. },
  105. {
  106. label: '未完成',
  107. value: 2,
  108. },
  109. {
  110. label: '已完成',
  111. value: 3,
  112. },
  113. {
  114. label: '已关闭',
  115. value: 4,
  116. }];
  117. },
  118. },
  119. assignmentOptions: {
  120. type: Array,
  121. default() {
  122. return [
  123. {
  124. label: '组员A',
  125. value: 1,
  126. },
  127. {
  128. label: '组员B',
  129. value: 2,
  130. },
  131. {
  132. label: '组员C',
  133. value: 3,
  134. },
  135. {
  136. label: '组员D',
  137. value: 4,
  138. }];
  139. },
  140. },
  141. },
  142. data() {
  143. return {
  144. isShowCheckbox: false,
  145. pageSize: 10,
  146. selectedId: [],
  147. status: null,
  148. assignment: null,
  149. };
  150. },
  151. methods: {
  152. showCheckbox() {
  153. this.isShowCheckbox = true;
  154. },
  155. handleSelectionChange(val) {
  156. console.warn(val);
  157. const tempArray = [];
  158. val.forEach((item) => {
  159. tempArray.push(item.projectCode);
  160. });
  161. this.selectedId = tempArray;
  162. },
  163. // 分页切换事件
  164. handleCurrentChange(currentPage) {
  165. console.log(currentPage);
  166. this.$emit('current-change', currentPage);
  167. },
  168. // 批量删除
  169. handleMultipleDelete() {
  170. console.warn('deleteMultiply');
  171. this.$emit('multiple-delete', this.selectedId);
  172. },
  173. // 批量修改状态
  174. handleMultipleStatusChange() {
  175. this.$emit('multiple-status-change', this.selectedId);
  176. },
  177. // 批量修改分配人
  178. handleMultipleAssignmentChange() {
  179. this.$emit('multiple-assignment-change', this.selectedId);
  180. },
  181. },
  182. };
  183. </script>
  184. <style scoped>
  185. </style>