index.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494
  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. <pre>{{scope.row.name}}</pre>
  125. </el-button>
  126. <span v-else><pre>{{scope.row.name}}</pre></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="注册时间" prop="createdTime" min-width="150px">
  143. <template slot-scope="{ row }">
  144. {{ parseTime(row.createdTime) }}
  145. </template>
  146. </el-table-column>
  147. <el-table-column label="状态" key="statusV">
  148. <template slot-scope="{ row, column }">
  149. <el-tag :type="JSON.parse(row.status).value == '1' ? 'success' : 'info'">{{ JSON.parse(row.status).desc }}</el-tag>
  150. </template>
  151. </el-table-column>
  152. <el-table-column
  153. label="操作"
  154. align="center"
  155. width="200"
  156. class-name="small-padding fixed-width"
  157. >
  158. <template slot-scope="scope" v-if="scope.row.userId !== 1">
  159. <el-button
  160. size="mini"
  161. type="text"
  162. @click="handleDetail(scope.row)"
  163. v-hasPermi="['business:channel:query']"
  164. >查看</el-button>
  165. <el-button
  166. size="mini"
  167. type="text"
  168. @click="handleUpdate(scope.row)"
  169. v-hasPermi="['business:channel:edit']"
  170. >编辑</el-button>
  171. <el-button
  172. size="mini"
  173. type="text"
  174. @click="handleStatusChange(scope.row)"
  175. v-hasPermi="['business:channel:edit']"
  176. >
  177. <span v-if="getValue(scope.row.status) == 1" > 停用</span>
  178. <span v-if="getValue(scope.row.status) == 2" > 启用</span>
  179. </el-button>
  180. <!-- <el-switch
  181. style="margin-left: 9px;"
  182. v-model="scope.row.statusV"
  183. active-value="1"
  184. inactive-value="2"
  185. v-hasPermi="['business:channel:edit']"
  186. @change="handleStatusChange(scope.row)"
  187. ></el-switch> -->
  188. <!-- <el-button
  189. size="mini"
  190. type="text"
  191. disabled
  192. icon="el-icon-plus"
  193. @click="handleAdd(scope.row)"
  194. v-hasPermi="['admin:channel:add']"
  195. >添加子渠道</el-button> -->
  196. </template>
  197. </el-table-column>
  198. </el-table>
  199. <pagination
  200. v-show="total>0"
  201. :total="total"
  202. :page.sync="pageParams.pageNum"
  203. :limit.sync="pageParams.pageSize"
  204. @pagination="getList"
  205. />
  206. </el-col>
  207. </el-row>
  208. <!-- 新建 -->
  209. <channel-create
  210. v-if="createShow"
  211. :dialog-visible="createShow"
  212. :edit-id="editId"
  213. @saveSuccess="submitSuccess"
  214. @close="hideDialog"
  215. />
  216. <!-- 详情 -->
  217. <channel-detail
  218. v-if="detailShow"
  219. :dialog-visible="detailShow"
  220. :edit-id="editId"
  221. @close="hideDialog"
  222. />
  223. </div>
  224. </template>
  225. <script>
  226. import { getToken } from "@/utils/auth";
  227. import { treeChannel, listChannel, updateChannelStatus} from "@/api/admin/channel";
  228. import { listAreaByPid} from "@/api/admin/area";
  229. import Treeselect from "@riophae/vue-treeselect";
  230. import "@riophae/vue-treeselect/dist/vue-treeselect.css";
  231. import ChannelCreate from './components/Create'
  232. import ChannelDetail from './components/Detail'
  233. export default {
  234. name: "Channel",
  235. components: {
  236. Treeselect,
  237. ChannelCreate,
  238. ChannelDetail
  239. },
  240. data() {
  241. return {
  242. // 遮罩层
  243. loading: true,
  244. // 导出遮罩层
  245. exportLoading: false,
  246. // 选中数组
  247. ids: [],
  248. // 创建编辑
  249. createShow: false,
  250. // 详情
  251. detailShow: false,
  252. provinceList:[],
  253. cityList:[],
  254. areaList:[],
  255. // 编辑项ID
  256. editId: null,
  257. // 显示搜索条件
  258. showSearch: true,
  259. // 总条数
  260. total: 0,
  261. // 用户表格数据
  262. channelList: [],
  263. channelOptions: [],
  264. channelName:"",
  265. // 状态数据字典
  266. statusOptions: [],
  267. // 表单参数
  268. form: {},
  269. defaultProps: {
  270. children: "children",
  271. label: "name"
  272. },
  273. // 查询参数
  274. queryParams: {
  275. name: "",
  276. mobile: "",
  277. provinceId:"",
  278. cityId:"",
  279. areaId:""
  280. },
  281. pageParams: {
  282. pageNum: 1,
  283. pageSize: 10,
  284. orderByColumn: 'channelId',
  285. isAsc: 'desc',
  286. }
  287. };
  288. },
  289. watch: {
  290. // 根据渠道名称筛选渠道树
  291. //channelName(val) {
  292. // this.$refs.tree.filter(val);
  293. //}
  294. },
  295. mounted() {
  296. this.getProvinceList()
  297. },
  298. created() {
  299. this.getList();
  300. },
  301. methods: {
  302. /** 查询用户列表 */
  303. getList() {
  304. this.loading = true;
  305. listChannel('pageNum='+this.pageParams.pageNum + '&pageSize='+this.pageParams.pageSize+'&orderByColumn='+ this.pageParams.orderByColumn +'&isAsc='+ this.pageParams.isAsc +'&', this.queryParams).then(response => {
  306. this.channelList = response.rows;
  307. this.channelList.forEach(item => {
  308. item.statusV = JSON.parse(item.status).value+""
  309. })
  310. this.total = response.total;
  311. this.loading = false;
  312. }
  313. );
  314. },
  315. // 节点单击事件
  316. handleNodeClick(data) {
  317. this.queryParams.parentId = data.channelId;
  318. this.getList();
  319. },
  320. // 懒加载节点
  321. loadNode(node, resolve) {
  322. if(node.level === 0){
  323. treeChannel({}).then(response => {
  324. return resolve(response.data);
  325. });
  326. }else{
  327. var params = {
  328. parentId:node.data.channelId
  329. }
  330. treeChannel(params).then(response => {
  331. return resolve(response.data);
  332. });
  333. }
  334. },
  335. //切换排序
  336. sortChannelId(row){
  337. if (row){
  338. let prop = row.prop == 'commRate' ? ('t1.'+ row.prop) : row.prop;
  339. this.pageParams.orderByColumn = prop
  340. this.pageParams.isAsc = row.order=='ascending'?"asc":"desc";
  341. this.getList()
  342. }
  343. },
  344. refreshChannelTree(){
  345. treeChannel({}).then(response => {
  346. this.channelOptions = response.data
  347. });
  348. },
  349. // 省
  350. getProvinceList(){
  351. this.cityList = []
  352. this.areaList = []
  353. this.queryParams.cityId = ""
  354. this.queryParams.areaId = ""
  355. listAreaByPid(0).then(response => {
  356. // console.log("getProvinceList"+JSON.stringify(response))
  357. this.provinceList = response || [];
  358. });
  359. },
  360. getCityList(){
  361. this.cityList = []
  362. this.areaList = []
  363. this.queryParams.cityId = ""
  364. this.queryParams.areaId = ""
  365. var provinceId = this.queryParams.provinceId
  366. listAreaByPid(provinceId).then(response => {
  367. // console.log("getCityList"+JSON.stringify(response))
  368. this.cityList = response || [];
  369. });
  370. },
  371. getAreaList(){
  372. var cityId = this.queryParams.cityId
  373. listAreaByPid(cityId).then(response => {
  374. // console.log("getAreaList"+JSON.stringify(response))
  375. this.areaList = response || [];
  376. });
  377. },
  378. // 状态修改
  379. handleStatusChange(row) {
  380. var newStatus = this.getValue(row.status) == 2?1:2
  381. let text = this.getValue(row.status) == 2 ? "启用" : "停用";
  382. this.$confirm('确认要"' + text + '""' + row.name + '"渠道吗?', "警告", {
  383. confirmButtonText: "确定",
  384. cancelButtonText: "取消",
  385. type: "warning"
  386. }).then(function() {
  387. var params={
  388. channelId:row.channelId,
  389. status: newStatus
  390. }
  391. return updateChannelStatus(params);
  392. }).then(() => {
  393. this.msgSuccess(text + "成功");
  394. this.getList();
  395. }).catch(function() {
  396. // row.status = row.status === "0" ? "1" : "0";
  397. });
  398. },
  399. /** 搜索按钮操作 */
  400. handleQuery() {
  401. this.pageParams.pageNum = 1;
  402. this.getList();
  403. },
  404. /** 重置按钮操作 */
  405. resetQuery() {
  406. this.queryParams= {
  407. name: "",
  408. mobile: "",
  409. provinceId:"",
  410. cityId:"",
  411. areaId:""
  412. },
  413. this.resetForm("queryForm");
  414. this.handleQuery();
  415. },
  416. handleDetail(row){
  417. this.detailShow = true
  418. this.editId = row.channelId
  419. },
  420. /** 新增按钮操作 */
  421. handleAdd() {
  422. this.createShow = true
  423. this.editId = null
  424. },
  425. /** 修改按钮操作 */
  426. handleUpdate(row) {
  427. this.createShow = true
  428. this.editId = row.channelId
  429. },
  430. // 保存后的操作
  431. submitSuccess(){
  432. this.getList();
  433. this.refreshChannelTree();
  434. },
  435. /**关闭弹窗*/
  436. hideDialog(){
  437. this.createShow = false
  438. this.detailShow = false
  439. },
  440. getDesc(val) {
  441. // console.log("val == "+val);
  442. const dataObj = JSON.parse(val);
  443. return (dataObj && dataObj.desc) || "";
  444. },
  445. getValue(val) {
  446. // console.log("val == "+val);
  447. const dataObj = JSON.parse(val);
  448. return (dataObj && dataObj.value) || "";
  449. },
  450. handleView(row) {
  451. // this.createShow = true
  452. let parentId = row.channelId
  453. let title = row.name
  454. // this.action = 'view'
  455. const path = "/channel/channel/childs"
  456. // const routerName = "BillItems"
  457. this.$router.push({
  458. path: path ,
  459. query: {
  460. parentId: parentId,
  461. title: title
  462. },
  463. meta:{
  464. title:"777777777777777777"
  465. }
  466. });
  467. },
  468. }
  469. };
  470. </script>
  471. <style lang="sass" scoped>
  472. </style>