index.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440
  1. <template>
  2. <div class="app-container">
  3. <el-row :gutter="20">
  4. <!--部门数据-->
  5. <el-col :span="4" :xs="24" >
  6. <div class="head-container">
  7. <!-- <el-input
  8. v-model="channelName"
  9. placeholder="请输入渠道名称"
  10. clearable
  11. size="small"
  12. prefix-icon="el-icon-search"
  13. style="margin-bottom: 20px"
  14. /> -->
  15. </div>
  16. <div class="head-container" style="overflow-x:scroll">
  17. <el-tree
  18. :props="defaultProps"
  19. ref="tree"
  20. :load="loadNode"
  21. :data="channelOptions"
  22. lazy
  23. @node-click="handleNodeClick"
  24. />
  25. </div>
  26. </el-col>
  27. <!--用户数据-->
  28. <el-col :span="20" :xs="24">
  29. <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
  30. <el-form-item label="渠道名称" prop="name">
  31. <el-input
  32. v-model="queryParams.name"
  33. placeholder="请输入渠道名称"
  34. clearable
  35. size="small"
  36. style="width: 240px"
  37. @keyup.enter.native="handleQuery"
  38. />
  39. </el-form-item>
  40. <el-form-item label="手机号码" prop="mobile">
  41. <el-input
  42. v-model="queryParams.mobile"
  43. placeholder="请输入手机号码"
  44. clearable
  45. size="small"
  46. style="width: 240px"
  47. @keyup.enter.native="handleQuery"
  48. />
  49. </el-form-item>
  50. <el-form-item label="地区">
  51. <el-select
  52. v-model="queryParams.provinceId"
  53. placeholder="选择省份"
  54. clearable
  55. size="small"
  56. @change="getCityList()"
  57. style="width: 120px;margin-right: 1px;">
  58. <el-option
  59. v-for="item in provinceList"
  60. :key="item.areaId"
  61. :label="item.areaName"
  62. :value="item.areaId"
  63. />
  64. </el-select>
  65. <el-select
  66. v-model="queryParams.cityId"
  67. placeholder="选择市"
  68. clearable
  69. size="small"
  70. @change="getAreaList()"
  71. style="width: 120px;margin-right: 1px;">
  72. <el-option
  73. v-for="item in cityList"
  74. :key="item.areaId"
  75. :label="item.areaName"
  76. :value="item.areaId"
  77. />
  78. </el-select>
  79. <el-select v-model="queryParams.areaId" placeholder="选择区" clearable size="small" style="width: 120px;margin-right: 1px;">
  80. <el-option
  81. v-for="item in areaList"
  82. :key="item.areaId"
  83. :label="item.areaName"
  84. :value="item.areaId"
  85. />
  86. </el-select>
  87. </el-form-item>
  88. <el-form-item>
  89. <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
  90. <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
  91. </el-form-item>
  92. </el-form>
  93. <el-row :gutter="10" class="mb8">
  94. <el-col :span="1.5">
  95. <el-button
  96. type="primary"
  97. icon="el-icon-plus"
  98. size="mini"
  99. @click="handleAdd"
  100. v-hasPermi="['system:user:add']"
  101. >添加一级渠道</el-button>
  102. </el-col>
  103. <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
  104. </el-row>
  105. <el-table v-loading="loading" :data="channelList">
  106. <el-table-column label="渠道ID" prop="channelId" width="100px" />
  107. <el-table-column label="渠道名称" prop="name" show-overflow-tooltip width="180px"/>
  108. <el-table-column label="手机号码" prop="mobile" show-overflow-tooltip width="120px"/>
  109. <el-table-column label="佣金比例" prop="commRate">
  110. <template slot-scope="scope">
  111. {{scope.row.commRate}}%
  112. </template>
  113. </el-table-column>
  114. <el-table-column label="渠道级别" prop="level">
  115. <template slot-scope="scope">
  116. {{scope.row.level}}级渠道
  117. </template>
  118. </el-table-column>
  119. <el-table-column label="经销商数" prop="siteCnt" />
  120. <el-table-column label="用户数" prop="userCnt" />
  121. <el-table-column label="状态" key="status">
  122. <template slot-scope="{ row, column }">
  123. <span v-if="getValue(row.status) == 1" style="color: blue;"> {{getDesc(row.status)}}</span>
  124. <span v-if="getValue(row.status) == 2" style="color: red;"> {{getDesc(row.status)}}</span>
  125. </template>
  126. </el-table-column>
  127. <el-table-column
  128. label="操作"
  129. align="center"
  130. width="200"
  131. class-name="small-padding fixed-width"
  132. >
  133. <template slot-scope="scope" v-if="scope.row.userId !== 1">
  134. <el-button
  135. size="mini"
  136. type="text"
  137. @click="handleDetail(scope.row)"
  138. v-hasPermi="['admin:channel:read']"
  139. >查看</el-button>
  140. <el-button
  141. size="mini"
  142. type="text"
  143. @click="handleUpdate(scope.row)"
  144. v-hasPermi="['admin:channel:edit']"
  145. >编辑</el-button>
  146. <el-button
  147. size="mini"
  148. type="text"
  149. @click="handleStatusChange(scope.row)"
  150. v-hasPermi="['admin:channel:edit']"
  151. >
  152. <span v-if="getValue(scope.row.status) == 1"> 停用</span>
  153. <span v-if="getValue(scope.row.status) == 2"> 启用</span>
  154. </el-button>
  155. <!-- <el-button
  156. size="mini"
  157. type="text"
  158. disabled
  159. icon="el-icon-plus"
  160. @click="handleAdd(scope.row)"
  161. v-hasPermi="['admin:channel:add']"
  162. >添加子渠道</el-button> -->
  163. </template>
  164. </el-table-column>
  165. </el-table>
  166. <pagination
  167. v-show="total>0"
  168. :total="total"
  169. :page.sync="pageParams.pageNum"
  170. :limit.sync="pageParams.pageSize"
  171. @pagination="getList"
  172. />
  173. </el-col>
  174. </el-row>
  175. <!-- 新建 -->
  176. <channel-create
  177. v-if="createShow"
  178. :dialog-visible="createShow"
  179. :edit-id="editId"
  180. @saveSuccess="submitSuccess"
  181. @close="hideDialog"
  182. />
  183. <!-- 详情 -->
  184. <channel-detail
  185. v-if="detailShow"
  186. :dialog-visible="detailShow"
  187. :edit-id="editId"
  188. @close="hideDialog"
  189. />
  190. </div>
  191. </template>
  192. <script>
  193. import { getToken } from "@/utils/auth";
  194. import { treeChannel, listChannel, updateChannelStatus} from "@/api/admin/channel";
  195. import { listAreaByPid} from "@/api/admin/area";
  196. import Treeselect from "@riophae/vue-treeselect";
  197. import "@riophae/vue-treeselect/dist/vue-treeselect.css";
  198. import ChannelCreate from './components/Create'
  199. import ChannelDetail from './components/Detail'
  200. export default {
  201. name: "ChannelIndex",
  202. components: {
  203. Treeselect,
  204. ChannelCreate,
  205. ChannelDetail
  206. },
  207. data() {
  208. return {
  209. // 遮罩层
  210. loading: true,
  211. // 导出遮罩层
  212. exportLoading: false,
  213. // 选中数组
  214. ids: [],
  215. // 创建编辑
  216. createShow: false,
  217. // 详情
  218. detailShow: false,
  219. provinceList:[],
  220. cityList:[],
  221. areaList:[],
  222. // 编辑项ID
  223. editId: null,
  224. // 显示搜索条件
  225. showSearch: true,
  226. // 总条数
  227. total: 0,
  228. // 用户表格数据
  229. channelList: [],
  230. channelOptions: [],
  231. channelName:"",
  232. // 状态数据字典
  233. statusOptions: [],
  234. // 表单参数
  235. form: {},
  236. defaultProps: {
  237. children: "children",
  238. label: "name"
  239. },
  240. // 查询参数
  241. queryParams: {
  242. name: "",
  243. mobile: "",
  244. provinceId:"",
  245. cityId:"",
  246. areaId:""
  247. },
  248. pageParams: {
  249. pageNum: 1,
  250. pageSize: 10
  251. }
  252. };
  253. },
  254. watch: {
  255. // 根据渠道名称筛选渠道树
  256. channelName(val) {
  257. this.$refs.tree.filter(val);
  258. }
  259. },
  260. mounted() {
  261. this.getProvinceList()
  262. },
  263. created() {
  264. this.getList();
  265. },
  266. methods: {
  267. /** 查询用户列表 */
  268. getList() {
  269. this.loading = true;
  270. listChannel('pageNum='+this.pageParams.pageNum + '&pageSize='+this.pageParams.pageSize+'&', this.queryParams).then(response => {
  271. this.channelList = response.rows;
  272. this.total = response.total;
  273. this.loading = false;
  274. }
  275. );
  276. },
  277. // 节点单击事件
  278. handleNodeClick(data) {
  279. this.queryParams.parentId = data.channelId;
  280. this.getList();
  281. },
  282. // 懒加载节点
  283. loadNode(node, resolve) {
  284. if(node.level === 0){
  285. treeChannel({}).then(response => {
  286. return resolve(response.data);
  287. });
  288. }else{
  289. var params = {
  290. parentId:node.data.channelId
  291. }
  292. treeChannel(params).then(response => {
  293. return resolve(response.data);
  294. });
  295. }
  296. },
  297. refreshChannelTree(){
  298. treeChannel({}).then(response => {
  299. this.channelOptions = response.data
  300. });
  301. },
  302. // 省
  303. getProvinceList(){
  304. this.cityList = []
  305. this.areaList = []
  306. this.queryParams.cityId = ""
  307. this.queryParams.areaId = ""
  308. listAreaByPid(0).then(response => {
  309. // console.log("getProvinceList"+JSON.stringify(response))
  310. this.provinceList = response || [];
  311. });
  312. },
  313. getCityList(){
  314. this.cityList = []
  315. this.areaList = []
  316. this.queryParams.cityId = ""
  317. this.queryParams.areaId = ""
  318. var provinceId = this.queryParams.provinceId
  319. listAreaByPid(provinceId).then(response => {
  320. // console.log("getCityList"+JSON.stringify(response))
  321. this.cityList = response || [];
  322. });
  323. },
  324. getAreaList(){
  325. var cityId = this.queryParams.cityId
  326. listAreaByPid(cityId).then(response => {
  327. // console.log("getAreaList"+JSON.stringify(response))
  328. this.areaList = response || [];
  329. });
  330. },
  331. // 状态修改
  332. handleStatusChange(row) {
  333. var newStatus = this.getValue(row.status) == 2?1:2
  334. let text = this.getValue(row.status) == 2 ? "启用" : "停用";
  335. this.$confirm('确认要"' + text + '""' + row.name + '"渠道吗?', "警告", {
  336. confirmButtonText: "确定",
  337. cancelButtonText: "取消",
  338. type: "warning"
  339. }).then(function() {
  340. var params={
  341. channelId:row.channelId,
  342. status: newStatus
  343. }
  344. return updateChannelStatus(params);
  345. }).then(() => {
  346. this.msgSuccess(text + "成功");
  347. this.getList();
  348. }).catch(function() {
  349. // row.status = row.status === "0" ? "1" : "0";
  350. });
  351. },
  352. /** 搜索按钮操作 */
  353. handleQuery() {
  354. this.queryParams.pageNum = 1;
  355. this.getList();
  356. },
  357. /** 重置按钮操作 */
  358. resetQuery() {
  359. this.queryParams= {
  360. pageNum: 1,
  361. pageSize: 10,
  362. name: "",
  363. mobile: "",
  364. provinceId:"",
  365. cityId:"",
  366. areaId:""
  367. },
  368. this.resetForm("queryForm");
  369. this.handleQuery();
  370. },
  371. handleDetail(row){
  372. this.detailShow = true
  373. this.editId = row.channelId
  374. },
  375. /** 新增按钮操作 */
  376. handleAdd() {
  377. this.createShow = true
  378. this.editId = null
  379. },
  380. /** 修改按钮操作 */
  381. handleUpdate(row) {
  382. this.createShow = true
  383. this.editId = row.channelId
  384. },
  385. // 保存后的操作
  386. submitSuccess(){
  387. this.getList();
  388. this.refreshChannelTree();
  389. },
  390. /**关闭弹窗*/
  391. hideDialog(){
  392. this.createShow = false
  393. this.detailShow = false
  394. },
  395. getDesc(val) {
  396. // console.log("val == "+val);
  397. const dataObj = JSON.parse(val);
  398. return (dataObj && dataObj.desc) || "";
  399. },
  400. getValue(val) {
  401. // console.log("val == "+val);
  402. const dataObj = JSON.parse(val);
  403. return (dataObj && dataObj.value) || "";
  404. },
  405. /** 删除按钮操作 */
  406. handleDelete(row) {
  407. const channelId = row.channelId;
  408. // this.$confirm('是否确认删除编号为"' + channelId + '"的数据项?', "警告", {
  409. // confirmButtonText: "确定",
  410. // cancelButtonText: "取消",
  411. // type: "warning"
  412. // }).then(function() {
  413. // return delUser(userIds);
  414. // }).then(() => {
  415. // this.getList();
  416. // this.msgSuccess("删除成功");
  417. // }).catch(() => {});
  418. }
  419. }
  420. };
  421. </script>
  422. <style lang="sass" scoped>
  423. </style>