index.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493
  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) 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 }">
  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 }">
  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 }">
  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" min-width="150" fixed="right">
  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. @click="handleUpdate(scope.row)"
  172. v-hasPermi="['business:salesite:edit']"
  173. >编辑</el-button>
  174. <el-button
  175. size="mini"
  176. type="text"
  177. @click="handleStatusChange(scope.row)"
  178. v-hasPermi="['business:salesite:edit']"
  179. >
  180. <span v-if="getValue(scope.row.status) == 1"> 停用</span>
  181. <span v-if="getValue(scope.row.status) == 2"> 启用</span>
  182. </el-button>
  183. <!-- <el-switch
  184. style="margin-left: 9px;"
  185. v-model="scope.row.statusV"
  186. active-value="1"
  187. inactive-value="2"
  188. @change="handleStatusChange(scope.row)"
  189. v-hasPermi="['business:salesite:edit']"
  190. ></el-switch> -->
  191. </template>
  192. </el-table-column>
  193. </el-table>
  194. <pagination
  195. v-show="total>0"
  196. :total="total"
  197. :page.sync="pageParams.pageNum"
  198. :limit.sync="pageParams.pageSize"
  199. @pagination="getList"
  200. />
  201. <!-- 新建 -->
  202. <add-site-create
  203. v-if="createShow"
  204. :dialog-visible="createShow"
  205. :edit-id="editId"
  206. @saveSuccess="submitSuccess"
  207. @close="hideDialog"
  208. />
  209. <!-- 详情 -->
  210. <site-detail
  211. v-if="detailShow"
  212. :dialog-visible="detailShow"
  213. :edit-id="editId"
  214. @close="hideDialog"
  215. />
  216. </div>
  217. </template>
  218. <script>
  219. import { listAllChannel} from "@/api/admin/channel";
  220. import { listAreaByPid} from "@/api/admin/area";
  221. import { listSaleSite, updateSaleSiteStatus,salesiteOrderExport } from "@/api/admin/salesite";
  222. import SiteCreate from './components/Create'
  223. import AddSiteCreate from './components/AddCreate'
  224. import SiteDetail from './components/Detail'
  225. export default {
  226. name: "Salesite",
  227. components: {
  228. AddSiteCreate,
  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. const dataObj = JSON.parse(val);
  392. return (dataObj && dataObj.desc) || "";
  393. },
  394. getValue(val) {
  395. const dataObj = JSON.parse(val);
  396. return (dataObj && dataObj.value) || "";
  397. },
  398. /** 搜索按钮操作 */
  399. handleQuery() {
  400. this.channelList = this.channelCopyList;
  401. this.pageParams.pageNum = 1;
  402. this.getList();
  403. },
  404. /** 重置按钮操作 */
  405. resetQuery() {
  406. this.queryParams= {
  407. parentId: "",
  408. mobile: "",
  409. provinceId:"",
  410. cityId:"",
  411. areaId:""
  412. },
  413. this.resetForm("queryForm");
  414. this.handleQuery();
  415. },
  416. // 多选框选中数据
  417. handleSelectionChange(selection) {
  418. this.ids = selection.map(item => item.postId)
  419. this.single = selection.length!=1
  420. this.multiple = !selection.length
  421. },
  422. handleDetail(row){
  423. this.detailShow = true
  424. this.editId = row.channelId
  425. },
  426. /** 新增按钮操作 */
  427. handleAdd() {
  428. this.createShow = true
  429. this.editId = null
  430. },
  431. /** 修改按钮操作 */
  432. handleUpdate(row) {
  433. this.editId = row.channelId
  434. this.createShow = true
  435. },
  436. // 保存后的操作
  437. submitSuccess(){
  438. this.getList();
  439. },
  440. /**关闭弹窗*/
  441. hideDialog(){
  442. this.createShow = false
  443. this.detailShow = false
  444. },
  445. // 状态修改
  446. handleStatusChange(row) {
  447. var newStatus = this.getValue(row.status) == 2?1:2
  448. let text = this.getValue(row.status) == 2 ? "启用" : "停用";
  449. this.$confirm('确认要"' + text + '""' + row.name + '"门店吗?', "警告", {
  450. confirmButtonText: "确定",
  451. cancelButtonText: "取消",
  452. type: "warning"
  453. }).then(function() {
  454. var params={
  455. channelId:row.channelId,
  456. status: newStatus
  457. }
  458. return updateSaleSiteStatus(params);
  459. }).then(() => {
  460. this.msgSuccess(text + "成功");
  461. this.getList();
  462. }).catch(function() {
  463. row.statusV = row.statusV === "1" ? "2" : "1";
  464. });
  465. }
  466. }
  467. };
  468. </script>