materialGroup.vue 8.4 KB

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