index.vue 15 KB

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