index.vue 14 KB

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