index.vue 14 KB

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