index.vue 12 KB

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