group.vue 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208
  1. <template lang="html">
  2. <div id="group">
  3. <el-row class="register">
  4. <el-col :span="24" class="btn">
  5. <el-row :gutter="10">
  6. <el-col :span="20"><h3>群组管理</h3></el-col>
  7. <!-- 批量导入按钮没加 -->
  8. <el-col :span="4"><el-button type="success" icon="el-icon-plus" @click="dialog = true">群组添加</el-button></el-col>
  9. </el-row>
  10. </el-col>
  11. <el-col :span="24" class="search">
  12. <el-col :span="5" class="searchInp"><el-input v-model="input" placeholder="请输入内容"></el-input></el-col>
  13. <el-col :span="2" class="searchBtn"><el-button icon="el-icon-search"></el-button></el-col>
  14. </el-col>
  15. <el-col :span="24" class="list">
  16. <el-table :data="tableData" style="width: 100%" border stripe>
  17. <el-table-column prop="name" align="center" label="群组名称"> </el-table-column>
  18. <el-table-column prop="charge" align="center" label="责任人"> </el-table-column>
  19. <el-table-column prop="tel" align="center" label="责任人电话"> </el-table-column>
  20. <el-table-column label="操作" align="center">
  21. <template v-slot="scoped">
  22. <el-row type="flex" justify="center">
  23. <el-col :span="6">
  24. <el-button size="mini" type="text" @click="openDialog(scoped.$index, 'udpate')">修改</el-button>
  25. </el-col>
  26. <el-col :span="6">
  27. <el-button size="mini" type="text" @click="openDialog(scoped.$index, 'assign')">分配人员</el-button>
  28. </el-col>
  29. </el-row>
  30. </template>
  31. </el-table-column>
  32. </el-table>
  33. <el-col class="paging">
  34. <el-pagination background layout="prev, pager, next" :total="1000"></el-pagination>
  35. </el-col>
  36. </el-col>
  37. </el-row>
  38. <el-dialog title="群组编辑" :visible.sync="dialog">
  39. <el-form :model="form" label-position="left" label-width="auto" style="padding: 0 5px;">
  40. <el-row>
  41. <el-col :span="24">
  42. <el-form-item label="群组名称">
  43. <el-input v-model="form.name" clearable></el-input>
  44. </el-form-item>
  45. <el-form-item label="责任人">
  46. <el-input v-model="form.charge" clearable></el-input>
  47. </el-form-item>
  48. <el-form-item label="责任人电话">
  49. <el-input v-model="form.tel" clearable></el-input>
  50. </el-form-item>
  51. </el-col>
  52. </el-row>
  53. </el-form>
  54. <div slot="footer" class="dialog-footer">
  55. <el-button @click="dialog = false">取 消</el-button>
  56. <el-button type="primary" @click="handleEdit">确 定</el-button>
  57. </div>
  58. </el-dialog>
  59. <el-dialog title="分配人员" :visible.sync="dialogAssign" style="padding:0 5rem;">
  60. <el-transfer v-model="assignFrom.personList" :data="personList" :titles="['未添加', '已添加']" :button-texts="['删除', '添加']"></el-transfer>
  61. <div slot="footer" class="dialog-footer">
  62. <el-button @click="dialogAssign = false">取 消</el-button>
  63. <el-button type="primary" @click="handleAssign">确 定</el-button>
  64. </div>
  65. </el-dialog>
  66. </div>
  67. </template>
  68. <script>
  69. export default {
  70. name: 'group',
  71. props: {},
  72. components: {},
  73. data: () => ({
  74. input: '',
  75. textarea: '',
  76. tableData: [
  77. {
  78. name: '群组1',
  79. charge: '责任人1',
  80. tel: '1100000000',
  81. personList: [1],
  82. },
  83. {
  84. name: '群组2',
  85. charge: '责任人2',
  86. tel: '1200000000',
  87. personList: [2, 3],
  88. },
  89. {
  90. name: '群组3',
  91. charge: '责任人3',
  92. tel: '1300000000',
  93. },
  94. {
  95. name: '群组4',
  96. charge: '责任人4',
  97. tel: '1400000000',
  98. },
  99. ],
  100. personList: [],
  101. value: '',
  102. dialog: false,
  103. dialogAssign: false,
  104. form: {},
  105. assignFrom: {},
  106. }),
  107. created() {
  108. let list = [];
  109. for (let i = 0; i < 10; i++) {
  110. list.push({
  111. key: i,
  112. label: `人员${i}`,
  113. });
  114. }
  115. this.$set(this, `personList`, list);
  116. },
  117. computed: {},
  118. methods: {
  119. handleEdit() {
  120. let chData = this.form;
  121. const { index, ...form } = chData;
  122. form['state'] = 1;
  123. console.log(index, form);
  124. if (index !== undefined) {
  125. this.$set(this.tableData, `${index}`, form);
  126. this.$message.success('修改成功');
  127. } else {
  128. this.tableData.push(form);
  129. }
  130. this.handleCancel();
  131. },
  132. handleCancel() {
  133. this.form = {};
  134. this.dialog = false;
  135. },
  136. openDialog(index, type) {
  137. let data = JSON.parse(JSON.stringify(this.tableData[index]));
  138. data[`index`] = index;
  139. if (type === 'update') {
  140. this.dialog = true;
  141. this.$set(this, `form`, data);
  142. } else {
  143. this.dialogAssign = true;
  144. this.$set(this, `assignFrom`, data);
  145. }
  146. },
  147. handleAssign() {
  148. let data = this.assignFrom;
  149. const { index, ...form } = data;
  150. this.$set(this.tableData[index], `personList`, form.personList);
  151. this.dialogAssign = false;
  152. },
  153. handleClose(done) {
  154. this.$confirm('确认关闭?')
  155. .then(_ => {
  156. done();
  157. })
  158. .catch(_ => {});
  159. },
  160. },
  161. };
  162. </script>
  163. <style lang="scss" scoped>
  164. h1,
  165. h2,
  166. h3,
  167. h4,
  168. h5,
  169. h6 {
  170. margin: 0;
  171. padding: 0;
  172. }
  173. .register {
  174. width: 100%;
  175. padding: 20px;
  176. }
  177. .btn {
  178. width: 100%;
  179. height: 40px;
  180. line-height: 40px;
  181. margin: 20px 0;
  182. }
  183. .search {
  184. height: 40px;
  185. line-height: 40px;
  186. margin: 0 0 20px 0;
  187. }
  188. .searchSel .el-select {
  189. border-radius: 0;
  190. }
  191. /deep/.searchInp .el-input__inner {
  192. border-radius: 0;
  193. }
  194. .searchBtn .el-button {
  195. border-radius: 0;
  196. }
  197. .paging {
  198. text-align: right;
  199. margin: 10px 0;
  200. }
  201. .sizeA {
  202. padding: 30px;
  203. }
  204. </style>