index.vue 14 KB

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