ChannelGrouping.vue 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288
  1. <template>
  2. <div>
  3. <templateTable :formList="formList" :searchData.sync="searchData" :tableConfig="tableConfig" :data="tableData"
  4. @getList="getList" :btnGroup="btnGroup" @handleSearchList="handleSearchList" :pagination="page">
  5. </templateTable>
  6. <el-dialog :title="dialogTitle" width="25%" :visible.sync="dialogVisibleadd">
  7. <div class="flex" style="line-height: 50px;">
  8. <span>渠道分组名称:</span>
  9. <el-input size="small" style="width:220px" v-model="name" placeholder="请输入渠道分组名称"></el-input>
  10. </div>
  11. <span slot="footer" class="dialog-footer">
  12. <el-button size="small" @click="dialogVisibleadd = false">取 消</el-button>
  13. <el-button type="primary" size="small" @click="sumbit">确 定</el-button>
  14. </span>
  15. </el-dialog>
  16. <el-dialog title="授权机构" width="25%" :visible.sync="dialogVisible">
  17. <el-tree ref="tree" :data="treedata" accordion :props="defaultProps" show-checkbox node-key="id"
  18. :default-checked-keys="treekeys" @check-change="treechange"
  19. :default-expand-all="expandshow" class="stafftree">
  20. </el-tree>
  21. <span slot="footer" class="dialog-footer">
  22. <el-button size="small" @click="dialogVisible = false">取 消</el-button>
  23. <el-button type="primary" size="small" @click="sumbitInstitution">确 定</el-button>
  24. </span>
  25. </el-dialog>
  26. </div>
  27. </template>
  28. <script>
  29. import templateTable from "@/components/TemplateTable/index.vue";
  30. import templateForm from "@/components/TemplateForm/index.vue";
  31. export default {
  32. name: "policyImport",
  33. components: { templateTable, templateForm },
  34. data() {
  35. return {
  36. dept: [],
  37. name: '',
  38. dialogTitle: '新增',
  39. rowId: '',
  40. dialogVisible: false,
  41. dialogVisibleadd: false,
  42. labelWidth: '100px',
  43. btnGroup: [
  44. {
  45. name: '新增',
  46. click: () => this.add()
  47. }
  48. ],
  49. formList: [
  50. {
  51. label: "渠道分组名称",
  52. prop: "name",
  53. type: "input",
  54. },
  55. ],
  56. searchData: {},
  57. page: {
  58. pageNum: 1,
  59. pageSize: 20,
  60. totalSize: 0
  61. },
  62. tableData: [],
  63. tableConfig: {
  64. columns: [
  65. {
  66. prop: "name",
  67. label: "渠道分组名称",
  68. type: "text"
  69. },
  70. {
  71. prop: "createTime",
  72. label: "创建时间",
  73. type: "text"
  74. },
  75. {
  76. prop: "updateBy",
  77. label: "操作人",
  78. type: "text"
  79. },
  80. ],
  81. loading: true,
  82. isPaginationShow: true,
  83. optBtns: [
  84. {
  85. type: "primary",
  86. label: "授权机构",
  87. click: (row, index) => {
  88. return this.uthorizedAgency(row)
  89. },
  90. },
  91. {
  92. type: "primary",
  93. label: "修改",
  94. click: (row, index) => {
  95. return this.handleTableUpload(row);
  96. },
  97. },
  98. {
  99. type: "primary",
  100. label: "删除",
  101. click: (row, index) => {
  102. return this.handleTableDatl(row);
  103. },
  104. },
  105. ],
  106. },
  107. treedata: [], //授权结构树
  108. defaultProps: {
  109. //自定义参数
  110. children: "children",
  111. label: "name",
  112. },
  113. treekeys: [],
  114. expandshow: false,
  115. };
  116. },
  117. created() {
  118. this.getList();
  119. this.$api.dept.findDeptTree("9", "").then((res) => {
  120. this.treedata = res.data;
  121. this.setDisabled(this.treedata)
  122. });
  123. },
  124. methods: {
  125. uthorizedAgency(row){
  126. this.rowId=row.id
  127. this.$api.sys
  128. .queryRelationList(row.id)
  129. .then(res => {
  130. if (res.code == 200) {
  131. this.dialogVisible=true
  132. setTimeout(()=>{
  133. this.dept=res.data
  134. this.$refs.tree.setCheckedKeys(res.data);
  135. },500)
  136. } else {
  137. this.$message.error(res.msg);
  138. }
  139. });
  140. },
  141. //获取选中节点
  142. treechange(item, node, self) {
  143. if(item.children.length==0){
  144. if (node === true) {
  145. this.dept.push(item.id)
  146. } else {
  147. let index = this.dept.indexOf(this.dept.filter(e=>e==item.id)[0]);
  148. if (index !== -1) {
  149. this.dept.splice(index, 1);
  150. }
  151. }
  152. }
  153. },
  154. // 向有children的节点上增加disabled属性
  155. setDisabled(treeData) {
  156. if (treeData) {
  157. treeData.forEach(item => {
  158. if (!item.deptType || item.deptType!=='D') {
  159. item.disabled = true
  160. this.setDisabled(item.children)
  161. }
  162. })
  163. }
  164. },
  165. // 查询
  166. handleSearchList(data) {
  167. this.getList(data);
  168. },
  169. add() {
  170. this.dialogVisibleadd = true
  171. this.dialogTitle = '新增'
  172. },
  173. handleTableDatl(row) {
  174. this.$confirm("确认删除该条数据吗?", "提示", {
  175. type: "warning",
  176. })
  177. .then(() => {
  178. this.$api.sys
  179. .sysChannelGradeDelete(row.id)
  180. .then(res => {
  181. if (res.code == 200) {
  182. this.getList();
  183. } else {
  184. this.$message.error(res.msg);
  185. }
  186. });
  187. })
  188. },
  189. sumbit() {
  190. if (this.name) {
  191. if (this.dialogTitle == '新增') {
  192. this.$api.sys
  193. .sysChannelGradeGrade({ name: this.name })
  194. .then(res => {
  195. if (res.code == 200) {
  196. this.getList();
  197. this.dialogVisibleadd = false
  198. } else {
  199. this.$message.error(res.msg);
  200. }
  201. });
  202. }
  203. else {
  204. this.$api.sys
  205. .sysChannelGradeUp(this.rowId, { name: this.name })
  206. .then(res => {
  207. if (res.code == 200) {
  208. this.getList();
  209. this.dialogVisibleadd = false
  210. } else {
  211. this.$message.error(res.msg);
  212. }
  213. });
  214. }
  215. }
  216. else {
  217. this.$message({
  218. message: '请输入渠道分组名称!',
  219. type: 'warning'
  220. });
  221. }
  222. },
  223. //列表数据
  224. getList(data) {
  225. this.tableConfig.loading = true;
  226. this.$api.sys
  227. .sysChannelGradePage({ ...data, ...this.page })
  228. .then(res => {
  229. if (res.code == 200) {
  230. this.tableData = res.data.content;
  231. this.page.pageNum = res.data.pageNum;
  232. this.page.pageSize = res.data.pageSize;
  233. this.page.totalSize = res.data.totalSize;
  234. this.tableConfig.loading = false;
  235. } else {
  236. this.tableData = [];
  237. this.$message.error(res.msg);
  238. this.page.totalSize = 0;
  239. this.tableConfig.loading = false;
  240. }
  241. });
  242. },
  243. sumbitInstitution(){
  244. this.$api.sys
  245. .sysChannelauthorized({ areaIdList: this.dept,id:this.rowId })
  246. .then(res => {
  247. if (res.code == 200) {
  248. this.getList();
  249. this.dialogVisible = false
  250. } else {
  251. this.$message.error(res.msg);
  252. }
  253. });
  254. },
  255. handleTableUpload(row) {
  256. this.name = row.name
  257. this.rowId = row.id
  258. this.dialogTitle = '编辑'
  259. this.dialogVisibleadd = true
  260. },
  261. }
  262. };
  263. </script>
  264. <style lang="scss" scoped>
  265. /deep/{
  266. .stafftree {
  267. // 不可全选样式
  268. .el-tree-node {
  269. .el-checkbox__input.is-disabled {
  270. display: none;
  271. }
  272. }
  273. }
  274. }
  275. </style>