group.vue 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258
  1. <template>
  2. <div>
  3. <el-row :gutter="10" class="mb8" style="margin: 15px;">
  4. <el-col :span="1.5">
  5. <el-button
  6. type="primary"
  7. plain
  8. icon="el-icon-plus"
  9. size="mini"
  10. @click="handleAdd"
  11. v-hasPermi="['qw:contactWayGroup:add']"
  12. >新增分组</el-button>
  13. </el-col>
  14. </el-row>
  15. <div>
  16. <el-table v-loading="loading" :data="materialGroupList"
  17. @row-click="changeCurrentRow"
  18. :row-style="rowStyle"
  19. :cell-style="setSellStyle" height="600px">
  20. <!-- 保留的列 -->
  21. <el-table-column label="组名" align="center" prop="groupName" >
  22. <template slot-scope="scope">
  23. <i v-if="scope.row.special" class="el-icon-star-off" style="color: #f56c6c"></i> <!-- 全部分组图标 -->
  24. <i v-else class="el-icon-folder" style="color: #1aa4ff"></i> <!-- 常规分组图标 -->
  25. {{ scope.row.groupName }}
  26. </template>
  27. </el-table-column>
  28. <el-table-column label="操作" align="center" class-name="small-padding fixed-width" width="100px">
  29. <template slot-scope="scope">
  30. <el-dropdown trigger="click">
  31. <span class="el-dropdown-link">
  32. <i class="el-icon-more"></i>
  33. </span>
  34. <el-dropdown-menu slot="dropdown">
  35. <el-dropdown-item icon="el-icon-edit" @click.native.prevent="handleUpdate(scope.row)">
  36. 修改
  37. </el-dropdown-item>
  38. <el-dropdown-item icon="el-icon-delete" @click.native.prevent="handleDelete(scope.row)">
  39. 删除
  40. </el-dropdown-item>
  41. </el-dropdown-menu>
  42. </el-dropdown>
  43. </template>
  44. </el-table-column>
  45. </el-table>
  46. </div>
  47. <!-- 添加或修改企业微信素材分组对话框 -->
  48. <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
  49. <el-form ref="form" :model="form" :rules="rules" label-width="80px">
  50. <el-form-item label="分组名称" prop="groupName">
  51. <el-input v-model="form.groupName" placeholder="请输入分组名称" />
  52. </el-form-item>
  53. </el-form>
  54. <div slot="footer" class="dialog-footer">
  55. <el-button type="primary" @click="submitForm">确 定</el-button>
  56. <el-button @click="cancel">取 消</el-button>
  57. </div>
  58. </el-dialog>
  59. </div>
  60. </template>
  61. <script>
  62. import { listContactWayGroup, getContactWayGroup, delContactWayGroup, addContactWayGroup, updateContactWayGroup, exportContactWayGroup } from "@/api/qw/contactWayGroup";
  63. export default {
  64. name: "contactWayGroup",
  65. data() {
  66. return {
  67. // 遮罩层
  68. loading: true,
  69. //列表选择行数
  70. currentRowId:null,
  71. //绑定行
  72. rowIndex:null,
  73. // 导出遮罩层
  74. exportLoading: false,
  75. // 选中数组
  76. ids: [],
  77. // 非单个禁用
  78. single: true,
  79. // 非多个禁用
  80. multiple: true,
  81. // 显示搜索条件
  82. showSearch: true,
  83. // 总条数
  84. total: 0,
  85. // 企业微信素材分组表格数据
  86. materialGroupList: [
  87. { materialGroupName: '全部分组', special: true },
  88. ],
  89. // 弹出层标题
  90. title: "",
  91. // 是否显示弹出层
  92. open: false,
  93. // 查询参数
  94. queryParams: {
  95. pageNum: 1,
  96. pageSize: null,
  97. groupName: null,
  98. companyId: null,
  99. },
  100. // 表单参数
  101. form: {},
  102. // 表单校验
  103. rules: {
  104. groupName: [
  105. { required: true, message: "分组名称不能为空", trigger: "blur" }
  106. ],
  107. }
  108. };
  109. },
  110. created() {
  111. this.getList();
  112. },
  113. methods: {
  114. /** 查询企业微信素材分组列表 */
  115. getList() {
  116. this.loading = true;
  117. listContactWayGroup(this.queryParams).then(response => {
  118. this.materialGroupList = response.rows;
  119. this.$emit('getGroupList', response.rows);
  120. this.total = response.total;
  121. this.loading = false;
  122. });
  123. },
  124. // 取消按钮
  125. cancel() {
  126. this.open = false;
  127. this.reset();
  128. },
  129. // 行数重置
  130. resetRow(){
  131. this.currentRowId=null,
  132. //绑定行
  133. this.rowIndex=null;
  134. },
  135. //绑定行
  136. rowStyle ({row, rowIndex}) {
  137. if (this.currentRowId === row.groupId) {
  138. this.rowIndex=rowIndex;
  139. }
  140. },
  141. //选定行的风格样式
  142. setSellStyle({ row, column, rowIndex, columnIndex }) {
  143. if(this.rowIndex==rowIndex){
  144. return "background: #3facff;#3facff;border: none;color: rgb(255, 255, 255)"
  145. }
  146. return "border: none;"
  147. },
  148. /** 单点某一行 */
  149. changeCurrentRow(row){
  150. this.$emit('selectGroupScreen', row.id);
  151. if (this.currentRowId === row.id){
  152. return
  153. }else{
  154. this.currentRowId = row.id
  155. }
  156. },
  157. // 表单重置
  158. reset() {
  159. this.form = {
  160. groupId: null,
  161. groupName: null,
  162. companyId: null,
  163. createTime: null,
  164. };
  165. this.resetForm("form");
  166. },
  167. /** 搜索按钮操作 */
  168. handleQuery() {
  169. this.queryParams.pageNum = 1;
  170. this.getList();
  171. },
  172. /** 重置按钮操作 */
  173. resetQuery() {
  174. this.resetForm("queryForm");
  175. this.handleQuery();
  176. },
  177. // 多选框选中数据
  178. handleSelectionChange(selection) {
  179. console.log("多选框选中数据",selection)
  180. this.ids = selection.map(item => item.id)
  181. this.single = selection.length!==1
  182. this.multiple = !selection.length
  183. },
  184. /** 新增按钮操作 */
  185. handleAdd() {
  186. this.reset();
  187. this.open = true;
  188. this.title = "添加企业微信素材分组";
  189. },
  190. /** 修改按钮操作 */
  191. handleUpdate(row) {
  192. this.reset();
  193. const id = row.id || this.ids
  194. getContactWayGroup(id).then(response => {
  195. this.form = response.data;
  196. this.open = true;
  197. this.title = "修改企业微信素材分组";
  198. });
  199. },
  200. /** 提交按钮 */
  201. submitForm() {
  202. this.$refs["form"].validate(valid => {
  203. if (valid) {
  204. if (this.form.id != null) {
  205. updateContactWayGroup(this.form).then(response => {
  206. this.msgSuccess("修改成功");
  207. this.open = false;
  208. this.getList();
  209. });
  210. } else {
  211. addContactWayGroup(this.form).then(response => {
  212. this.msgSuccess("新增成功");
  213. this.open = false;
  214. this.getList();
  215. });
  216. }
  217. }
  218. });
  219. },
  220. /** 删除按钮操作 */
  221. handleDelete(row) {
  222. const id = row.id || this.ids;
  223. this.$confirm('是否确认删除企业微信素材分组编号为"' + id + '"的数据项?', "警告", {
  224. confirmButtonText: "确定",
  225. cancelButtonText: "取消",
  226. type: "warning"
  227. }).then(function() {
  228. return delContactWayGroup(id);
  229. }).then(() => {
  230. this.getList();
  231. this.msgSuccess("删除成功");
  232. }).catch(() => {});
  233. },
  234. /** 导出按钮操作 */
  235. handleExport() {
  236. const queryParams = this.queryParams;
  237. this.$confirm('是否确认导出所有企业微信素材分组数据项?', "警告", {
  238. confirmButtonText: "确定",
  239. cancelButtonText: "取消",
  240. type: "warning"
  241. }).then(() => {
  242. this.exportLoading = true;
  243. return exportContactWayGroup(queryParams);
  244. }).then(response => {
  245. this.download(response.msg);
  246. this.exportLoading = false;
  247. }).catch(() => {});
  248. }
  249. }
  250. };
  251. </script>