index.vue 13 KB

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