childs.vue 14 KB

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