index.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451
  1. <template>
  2. <div class="app-container">
  3. <el-form
  4. :model="queryParams"
  5. ref="queryForm"
  6. :inline="true"
  7. v-show="showSearch"
  8. label-width="75px"
  9. >
  10. <el-form-item label="上级渠道" prop="parentId">
  11. <el-select
  12. v-model="queryParams.parentId"
  13. placeholder="请选择上级渠道"
  14. style="width: 100%;"
  15. filterable
  16. clearable
  17. :filter-method="dataFilter"
  18. @change="handleQuery"
  19. >
  20. <el-option
  21. v-for="(item, index) in channelList"
  22. :key="item.channelId"
  23. :label="item.name"
  24. :value="item.channelId">
  25. <div>
  26. <span style="float: left;">{{item.name}} </span>
  27. <span style="float: right;">{{item.mobile}}</span>
  28. </div>
  29. </el-option>
  30. </el-select>
  31. </el-form-item>
  32. <el-form-item label="经销商名称" prop="name" label-width="90px">
  33. <el-input
  34. v-model="queryParams.name"
  35. placeholder="请输入经销商名称"
  36. clearable
  37. size="small"
  38. @keyup.enter.native="handleQuery"
  39. />
  40. </el-form-item>
  41. <el-form-item label="手机号码" prop="mobile">
  42. <el-input
  43. v-model="queryParams.mobile"
  44. placeholder="请输入手机号码"
  45. clearable
  46. size="small"
  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. disabled
  100. @click="handleAdd"
  101. v-hasPermi="['system:post:add']"
  102. >添加经销商</el-button>
  103. </el-col> -->
  104. <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
  105. </el-row>
  106. <el-table v-loading="loading" :data="siteList" @selection-change="handleSelectionChange">
  107. <!-- <el-table-column type="selection" width="55" /> -->
  108. <el-table-column label="经销商编号" prop="channelId" width="100px"/>
  109. <el-table-column label="经销商名称" show-overflow-tooltip prop="name" max-width="100px" />
  110. <el-table-column label="手机号码" prop="mobile" width="120px"/>
  111. <el-table-column label="佣金比例" prop="commRate">
  112. <template slot-scope="{ row, column }">
  113. <span>{{row.commRate}}%</span>
  114. </template>
  115. </el-table-column>
  116. <el-table-column label="上级渠道" prop="parentsName" min-width="170px" />
  117. <el-table-column label="盲票库存" prop="offLineQtyCnt" />
  118. <el-table-column label="线下销量" prop="offLineSaleCnt" />
  119. <el-table-column label="线上销量" prop="onLineSaleCnt" />
  120. <el-table-column label="用户数" prop="userCnt" />
  121. <el-table-column label="认证状态" prop="certifyStatus" >
  122. <template slot-scope="{ row, column }">
  123. <span v-if="getValue(row.certifyStatus) == 'y'" style="color: blue;"> {{getDesc(row.certifyStatus)}}</span>
  124. <span v-if="getValue(row.certifyStatus) == 'n'" style="color: red;"> {{getDesc(row.certifyStatus)}}</span>
  125. </template>
  126. </el-table-column>
  127. <el-table-column label="状态" key="statusV">
  128. <template slot-scope="{ row, column }">
  129. <el-tag :type="JSON.parse(row.status).value == '1' ? 'success' : 'info'">{{ JSON.parse(row.status).desc }}</el-tag>
  130. </template>
  131. <!-- <template slot-scope="scope">
  132. <el-switch
  133. v-model="scope.row.statusV"
  134. active-value="1"
  135. inactive-value="2"
  136. @change="handleStatusChange(scope.row)"
  137. ></el-switch>
  138. </template> -->
  139. </el-table-column>
  140. <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
  141. <template slot-scope="scope">
  142. <el-button
  143. size="mini"
  144. type="text"
  145. @click="handleDetail(scope.row)"
  146. v-hasPermi="['business:salesite:query']"
  147. >查看</el-button>
  148. <!-- <el-button
  149. size="mini"
  150. type="text"
  151. disabled
  152. @click="handleUpdate(scope.row)"
  153. v-hasPermi="['admin:salesite:edit']"
  154. >编辑</el-button> -->
  155. <el-button
  156. size="mini"
  157. type="text"
  158. @click="handleStatusChange(scope.row)"
  159. v-hasPermi="['admin:salesite:edit']"
  160. >
  161. <span v-if="getValue(scope.row.status) == 1"> 停用</span>
  162. <span v-if="getValue(scope.row.status) == 2"> 启用</span>
  163. </el-button>
  164. <!-- <el-switch
  165. style="margin-left: 9px;"
  166. v-model="scope.row.statusV"
  167. active-value="1"
  168. inactive-value="2"
  169. @change="handleStatusChange(scope.row)"
  170. v-hasPermi="['business:salesite:edit']"
  171. ></el-switch> -->
  172. </template>
  173. </el-table-column>
  174. </el-table>
  175. <pagination
  176. v-show="total>0"
  177. :total="total"
  178. :page.sync="pageParams.pageNum"
  179. :limit.sync="pageParams.pageSize"
  180. @pagination="getList"
  181. />
  182. <!-- 新建 -->
  183. <site-create
  184. v-if="createShow"
  185. :dialog-visible="createShow"
  186. :edit-id="editId"
  187. @saveSuccess="submitSuccess"
  188. @close="hideDialog"
  189. />
  190. <!-- 详情 -->
  191. <site-detail
  192. v-if="detailShow"
  193. :dialog-visible="detailShow"
  194. :edit-id="editId"
  195. @close="hideDialog"
  196. />
  197. </div>
  198. </template>
  199. <script>
  200. import { listAllChannel} from "@/api/admin/channel";
  201. import { listAreaByPid} from "@/api/admin/area";
  202. import { listSaleSite, updateSaleSiteStatus} from "@/api/admin/salesite";
  203. import SiteCreate from './components/Create'
  204. import SiteDetail from './components/Detail'
  205. export default {
  206. name: "SaleSiteIndex",
  207. components: {
  208. SiteCreate,
  209. SiteDetail
  210. },
  211. data() {
  212. return {
  213. // 遮罩层
  214. loading: true,
  215. // 创建编辑
  216. createShow: false,
  217. // 详情
  218. detailShow: false,
  219. // 编辑项ID
  220. editId: null,
  221. // 导出遮罩层
  222. exportLoading: false,
  223. // 选中数组
  224. ids: [],
  225. // 上级渠道列表
  226. channelList:[],
  227. channelCopyList:[],
  228. provinceList:[],
  229. cityList:[],
  230. areaList:[],
  231. // 非单个禁用
  232. single: true,
  233. // 非多个禁用
  234. multiple: true,
  235. // 显示搜索条件
  236. showSearch: true,
  237. // 总条数
  238. total: 0,
  239. // 经销商表格数据
  240. siteList: [],
  241. // 弹出层标题
  242. title: "",
  243. // 是否显示弹出层
  244. open: false,
  245. // 状态数据字典
  246. statusOptions: [],
  247. // 查询参数
  248. queryParams: {
  249. parentId: "",
  250. name: "",
  251. mobile: "",
  252. provinceId:"",
  253. cityId:"",
  254. areaId:""
  255. },
  256. pageParams: {
  257. pageNum: 1,
  258. pageSize: 10
  259. },
  260. // 表单参数
  261. form: {},
  262. };
  263. },
  264. mounted() {
  265. this.getChannelList()
  266. this.getProvinceList()
  267. },
  268. created() {
  269. this.getList();
  270. this.getDicts("sys_normal_disable").then(response => {
  271. this.statusOptions = response.data;
  272. });
  273. },
  274. methods: {
  275. /** 查询经销商列表 */
  276. getList() {
  277. this.loading = true;
  278. listSaleSite('pageNum='+this.pageParams.pageNum + '&pageSize='+this.pageParams.pageSize+'&',this.queryParams).then(response => {
  279. this.siteList = response.rows;
  280. this.siteList.forEach(item => {
  281. item.statusV = JSON.parse(item.status).value+""
  282. })
  283. this.total = response.total;
  284. this.loading = false;
  285. });
  286. },
  287. // 获取上级渠道下拉列表
  288. getChannelList(){
  289. listAllChannel().then(response => {
  290. this.channelList = response.data || [];
  291. this.channelCopyList = response.data || [];
  292. });
  293. },
  294. // 省
  295. getProvinceList(){
  296. this.cityList = []
  297. this.areaList = []
  298. this.queryParams.cityId = ""
  299. this.queryParams.areaId = ""
  300. listAreaByPid(0).then(response => {
  301. // console.log("getProvinceList"+JSON.stringify(response))
  302. this.provinceList = response || [];
  303. });
  304. },
  305. getCityList(){
  306. this.cityList = []
  307. this.areaList = []
  308. this.queryParams.cityId = ""
  309. this.queryParams.areaId = ""
  310. var provinceId = this.queryParams.provinceId
  311. listAreaByPid(provinceId).then(response => {
  312. // console.log("getCityList"+JSON.stringify(response))
  313. this.cityList = response || [];
  314. });
  315. },
  316. getAreaList(){
  317. var cityId = this.queryParams.cityId
  318. listAreaByPid(cityId).then(response => {
  319. // console.log("getAreaList"+JSON.stringify(response))
  320. this.areaList = response || [];
  321. });
  322. },
  323. dataFilter(val) {
  324. if (val) { //val存在
  325. this.channelList = this.channelCopyList.filter((item) => {
  326. if (!!~item.mobile.indexOf(val) || !!~item.mobile.toUpperCase().indexOf(val.toUpperCase())
  327. || !!~item.name.indexOf(val) || !!~item.name.indexOf(val)) {
  328. return true
  329. }
  330. })
  331. } else { //val为空时,还原数组
  332. this.channelList = this.channelCopyList;
  333. }
  334. console.log("this.channelList == "+JSON.stringify(this.channelList))
  335. console.log("this.channelCopyList == "+JSON.stringify(this.channelCopyList))
  336. },
  337. // 岗位状态字典翻译
  338. statusFormat(row, column) {
  339. return this.selectDictLabel(this.statusOptions, row.status);
  340. },
  341. getDesc(val) {
  342. // console.log("val == "+val);
  343. const dataObj = JSON.parse(val);
  344. return (dataObj && dataObj.desc) || "";
  345. },
  346. getValue(val) {
  347. // console.log("val == "+val);
  348. const dataObj = JSON.parse(val);
  349. return (dataObj && dataObj.value) || "";
  350. },
  351. submitSuccess(){
  352. this.getList();
  353. },
  354. hideDialog(){
  355. this.createShow = false
  356. this.detailShow = false
  357. },
  358. /** 搜索按钮操作 */
  359. handleQuery() {
  360. this.channelList = this.channelCopyList;
  361. this.queryParams.pageNum = 1;
  362. this.getList();
  363. },
  364. /** 重置按钮操作 */
  365. resetQuery() {
  366. this.queryParams= {
  367. parentId: "",
  368. name: "",
  369. mobile: "",
  370. provinceId:"",
  371. cityId:"",
  372. areaId:""
  373. },
  374. this.resetForm("queryForm");
  375. this.handleQuery();
  376. },
  377. // 多选框选中数据
  378. handleSelectionChange(selection) {
  379. this.ids = selection.map(item => item.postId)
  380. this.single = selection.length!=1
  381. this.multiple = !selection.length
  382. },
  383. handleDetail(row){
  384. this.detailShow = true
  385. this.editId = row.channelId
  386. },
  387. /** 新增按钮操作 */
  388. handleAdd() {
  389. this.createShow = true
  390. this.editId = null
  391. },
  392. /** 修改按钮操作 */
  393. handleUpdate(row) {
  394. this.createShow = true
  395. this.editId = row.channelId
  396. },
  397. // 保存后的操作
  398. submitSuccess(){
  399. this.getList();
  400. },
  401. /**关闭弹窗*/
  402. hideDialog(){
  403. this.createShow = false
  404. this.detailShow = false
  405. },
  406. // 状态修改
  407. handleStatusChange(row) {
  408. var newStatus = this.getValue(row.status) == 2?1:2
  409. let text = this.getValue(row.status) == 2 ? "启用" : "停用";
  410. this.$confirm('确认要"' + text + '""' + row.name + '"经销商吗?', "警告", {
  411. confirmButtonText: "确定",
  412. cancelButtonText: "取消",
  413. type: "warning"
  414. }).then(function() {
  415. var params={
  416. channelId:row.channelId,
  417. status: newStatus
  418. }
  419. return updateSaleSiteStatus(params);
  420. }).then(() => {
  421. this.msgSuccess(text + "成功");
  422. this.getList();
  423. }).catch(function() {
  424. row.statusV = row.statusV === "1" ? "2" : "1";
  425. });
  426. }
  427. }
  428. };
  429. </script>