index.vue 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753
  1. <template>
  2. <div class="app-container">
  3. <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch">
  4. <el-form-item label="代理商名称" prop="name">
  5. <el-input
  6. v-model="queryParams.name"
  7. placeholder="请输入代理商名称"
  8. clearable
  9. @keyup.enter.native="handleQuery"
  10. />
  11. </el-form-item>
  12. <el-form-item label="代理商等级" prop="agentLevel">
  13. <el-select v-model="queryParams.agentLevel" placeholder="请选择代理商等级" clearable >
  14. <el-option
  15. v-for="item in agentLevelList"
  16. :key="item.level"
  17. :label="item.name"
  18. :value="item.level"
  19. ></el-option>
  20. </el-select>
  21. </el-form-item>
  22. <el-form-item label="联系人" prop="contactName">
  23. <el-input
  24. v-model="queryParams.contactName"
  25. placeholder="请输入联系人"
  26. clearable
  27. @keyup.enter.native="handleQuery"
  28. />
  29. </el-form-item>
  30. <el-form-item label="联系手机" prop="mobile">
  31. <el-input
  32. v-model="queryParams.mobile"
  33. placeholder="请输入联系手机"
  34. clearable
  35. @keyup.enter.native="handleQuery"
  36. />
  37. </el-form-item>
  38. <el-form-item label="代理商地区">
  39. <OldSend :sendAreaProp="sendAreaProp" @changeArea="changeSendArea" ref="sendArea"/>
  40. </el-form-item>、
  41. <el-form-item label="创建时间" prop="createTime">
  42. <el-date-picker
  43. v-model="date"
  44. type="datetimerange"
  45. start-placeholder="开始时间"
  46. range-separator="至"
  47. end-placeholder="结束时间"
  48. :default-time="['00:00:00', '23:59:59']"
  49. value-format="yyyy-MM-dd HH:mm:ss"
  50. format="yyyy-MM-dd HH:mm:ss"></el-date-picker>
  51. </el-form-item>
  52. <el-form-item>
  53. <el-button type="primary" icon="el-icon-search" @click="handleQuery">搜索</el-button>
  54. <el-button icon="el-icon-refresh" @click="resetQuery">重置</el-button>
  55. </el-form-item>
  56. </el-form>
  57. <el-row :gutter="10" class="mb8">
  58. <el-col :span="1.5">
  59. <el-button
  60. type="primary"
  61. plain
  62. icon="el-icon-plus"
  63. @click="handleAdd"
  64. v-hasPermi="['module:agent:add']"
  65. >新增</el-button>
  66. </el-col>
  67. <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
  68. </el-row>
  69. <el-table v-loading="loading" :data="agentList" stripe border highlight-current-row style="width: 100%">
  70. <el-table-column prop="avatar" header-align="center" align="center" label="代理商头像">
  71. <template slot-scope="scope">
  72. <img :src="scope.row.avatar" style="width:50px;height:50px;" />
  73. </template>
  74. </el-table-column>
  75. <el-table-column label="代理商名称" align="center" prop="name" />
  76. <el-table-column label="联系人" align="center" prop="contactName" />
  77. <el-table-column label="联系手机" align="center" prop="mobile" />
  78. <el-table-column label="上级代理" align="center" class-name="small-padding fixed-width" show-overflow-tooltip>
  79. <template slot-scope="scope">
  80. <el-button v-if="scope.row.pid"
  81. type="text"
  82. @click="gotoInfo(scope.row.pid)"
  83. >{{scope.row.pagentName}}</el-button>
  84. </template>
  85. </el-table-column>
  86. <el-table-column label="所在省" align="center" prop="provinceName" />
  87. <el-table-column label="所在城市" align="center" prop="cityName" />
  88. <el-table-column label="所在区" align="center" prop="districtName" show-overflow-tooltip />
  89. <el-table-column label="二维码" align="center" prop="qrCode" >
  90. <template slot-scope="scope">
  91. <img style="width: 50px;height: 50px" :src="scope.row.qrCode">
  92. </template>
  93. </el-table-column>
  94. <el-table-column label="代理商等级" align="center" prop="levelName" />
  95. <el-table-column label="佣金类型" align="center" prop="type">
  96. <template slot-scope="scope">
  97. <span v-if="scope.row.type == 0">比例</span>
  98. <span v-if="scope.row.type == 1">金额</span>
  99. </template>
  100. </el-table-column>
  101. <el-table-column label="佣金" align="center" prop="commissionRate">
  102. <template slot-scope="scope">
  103. {{ scope.row.commissionRate }}
  104. <span v-if="scope.row.type == 0">%</span>
  105. <span v-if="scope.row.type == 1">元</span>
  106. </template>
  107. </el-table-column>
  108. <!-- <el-table-column label="佣金比率(%)" align="center" prop="commissionRate" /> -->
  109. <el-table-column label="货拉拉佣金金额(单位:元)" align="center" prop="huolalaCommission">
  110. <template slot-scope="scope">
  111. {{ scope.row.huolalaCommission }}
  112. </template>
  113. </el-table-column>
  114. <el-table-column label="绑定三方运力佣金比例" align="center" prop="bindingThirdCommission">
  115. <template slot-scope="scope">
  116. {{ scope.row.bindingThirdCommission }}%
  117. </template>
  118. </el-table-column>
  119. <el-table-column label="备注" align="center" prop="remark" />
  120. <el-table-column label="优惠包名称" align="center" v-if="user.type != 2">
  121. <template slot-scope="scope">
  122. <span>{{ scope.row.packageDiscountName || '- -' }}</span>
  123. </template>
  124. </el-table-column>
  125. <el-table-column label="佣金包名称" align="center" v-if="user.type != 2">
  126. <template slot-scope="scope">
  127. <span>{{ scope.row.packageCommissionName || '- -' }}</span>
  128. </template>
  129. </el-table-column>
  130. <el-table-column label="创建时间" align="center" prop="createTime" />
  131. <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
  132. <template slot-scope="scope">
  133. <el-button
  134. size="mini"
  135. type="text"
  136. @click="gotoInfo(scope.row.id)"
  137. >详情</el-button>
  138. <el-button
  139. size="mini"
  140. type="text"
  141. icon="el-icon-edit"
  142. @click="handleUpdate(scope.row)"
  143. v-if="scope.row.isEdit == 1"
  144. v-hasPermi="['module:agent:edit']"
  145. >修改</el-button>
  146. <el-button
  147. v-if="user.type != 2"
  148. size="mini"
  149. type="text"
  150. @click="handleDiscount(scope.row.id, 1)"
  151. >绑定优惠包</el-button>
  152. <el-button
  153. v-if="user.type != 2"
  154. size="mini"
  155. type="text"
  156. @click="handleCommission(scope.row.id, 2)"
  157. >绑定佣金包</el-button>
  158. </template>
  159. </el-table-column>
  160. </el-table>
  161. <pagination
  162. v-show="total>0"
  163. :total="total"
  164. :page.sync="queryParams.pageNum"
  165. :limit.sync="queryParams.pageSize"
  166. @pagination="getList"
  167. />
  168. <!-- 添加或修改代理商对话框 -->
  169. <el-dialog :title="title" :visible.sync="open" width="800px" append-to-body>
  170. <el-form ref="form" :model="form" :rules="rules" label-width="230px">
  171. <el-form-item label="代理商名称" prop="name">
  172. <el-input v-model="form.name" placeholder="请输入代理商名称" style="width:450px" />
  173. </el-form-item>
  174. <el-form-item label="代理商头像" prop="avatar" v-if="form.isPid == 0 || this.title == '添加代理商'">
  175. <materialLibrary v-model="form.avatar" :pickNum="1" ></materialLibrary>
  176. </el-form-item>
  177. <el-form-item label="联系人" prop="contactName">
  178. <el-input v-model="form.contactName" placeholder="请输入联系人" style="width:250px" />
  179. </el-form-item>
  180. <el-form-item label="联系手机" prop="mobile">
  181. <el-input v-model="form.mobile" placeholder="请输入联系手机" style="width:250px" />
  182. </el-form-item>
  183. <el-form-item label="所在地区" v-if="form.isPid == 0 || this.title == '添加代理商'">
  184. <span style="color: #f56c6c;float: left;position: absolute;left: -77px;">*</span>
  185. <Area :provinceAndCity="areaProp" @changeArea="changeArea" ref="area"/>
  186. </el-form-item>
  187. <el-form-item label="代理商等级" prop="agentLevel" v-if="form.isPid == 0 || this.title == '添加代理商'">
  188. <el-select v-model="form.agentLevel" placeholder="请选择代理商等级" clearable >
  189. <el-option
  190. v-for="item in agentLevelList"
  191. :key="item.level"
  192. :label="item.name"
  193. :value="item.level"
  194. :disabled="item.isNone == 1"
  195. ></el-option>
  196. </el-select>
  197. </el-form-item>
  198. <el-form-item label="佣金类型" prop="type" v-if="form.isPid == 0 || this.title == '添加代理商'">
  199. <el-radio-group v-model="form.type">
  200. <el-radio :label="0" :disabled="this.title == '修改代理商'">比例</el-radio>
  201. <el-radio :label="1" :disabled="this.title == '修改代理商'">金额</el-radio>
  202. </el-radio-group>
  203. </el-form-item>
  204. <el-form-item :label="form.type == 0 ? '佣金比例' : '佣金金额'" prop="commissionRate">
  205. <div v-if="form.type == 0">
  206. <el-input-number :disabled="this.title == '修改代理商'" style="width:330px" :min="0" controls-position="right" :max="maxRate" v-model="form.commissionRate" :placeholder="'可输入佣金比率范围0~' + maxRate">
  207. </el-input-number> %
  208. </div>
  209. <div v-if="form.type == 1">
  210. <el-input-number :disabled="this.title == '修改代理商'" style="width:330px" :min="0" controls-position="right" :max="qishouMax" :precision="2" v-model="form.commissionRate" :placeholder="'可输入佣金金额范围0~' + qishouMax">
  211. </el-input-number> 元
  212. </div>
  213. </el-form-item>
  214. <el-form-item label="货拉拉佣金金额(单位:元)" prop="huolalaCommission">
  215. <el-input-number :disabled="this.title == '修改代理商'" style="width:330px" :min="0" controls-position="right" :max="huolalaMax" :precision="2" v-model="form.huolalaCommission" :placeholder="'可输入货拉拉佣金金额范围0~' + huolalaMax">
  216. </el-input-number>
  217. </el-form-item>
  218. <!-- <el-form-item label="绑定三方运力佣金比例" prop="bindingThirdCommission" v-if="form.isPid == 0 || this.title == '添加代理商'">
  219. <el-input-number style="width:330px" :min="0" controls-position="right" :max="100" v-model="form.bindingThirdCommission" placeholder="请输入绑定三方运力佣金比例">
  220. </el-input-number> %
  221. </el-form-item>
  222. <el-form-item label="绑定三方运力佣金比例" prop="bindingThirdCommission" v-if="form.isPid != 0 && this.title == '修改代理商'">
  223. <el-input-number style="width:330px" :min="0" controls-position="right" :max="bindingThirdMax" v-model="form.bindingThirdCommission" :placeholder="'可输入绑定三方运力佣金比例范围0~' + bindingThirdMax">
  224. </el-input-number> %
  225. </el-form-item> -->
  226. <el-form-item label="绑定三方运力佣金比例" prop="bindingThirdCommission">
  227. <el-input-number :disabled="this.title == '修改代理商'" style="width:330px" :min="0" controls-position="right" :max="100" v-model="form.bindingThirdCommission" placeholder="请输入绑定三方运力佣金比例">
  228. </el-input-number> %
  229. </el-form-item>
  230. <!-- <el-form-item label="佣金比率" prop="commissionRate" v-if="form.isPid == 0 || this.title == '添加代理商'">
  231. <el-input-number style="width:250px" :min="0" controls-position="right" :max="maxRate" :precision="2" v-model="form.commissionRate" :placeholder="'可输入佣金比率范围0~' + maxRate">
  232. </el-input-number> %
  233. </el-form-item> -->
  234. <el-form-item label="地址" prop="address" v-if="form.isPid == 0 || this.title == '添加代理商'">
  235. <el-input v-model="form.address" placeholder="请输入地址" style="width:450px" />
  236. </el-form-item>
  237. <el-form-item label="备注" prop="remark">
  238. <el-input v-model="form.remark" placeholder="请输入备注" maxlength="50" style="width:450px" />
  239. </el-form-item>
  240. </el-form>
  241. <div slot="footer" class="dialog-footer">
  242. <el-button type="primary" @click="submitForm">确 定</el-button>
  243. <el-button @click="cancel">取 消</el-button>
  244. </div>
  245. </el-dialog>
  246. <el-dialog title="绑定包配置" :visible.sync="packageRequestOpen" width="700px" append-to-body>
  247. <el-form ref="packageRequest" :model="packageRequest" :rules="packageRequestRules" label-width="130px">
  248. <el-form-item label="选择包" prop="packageId">
  249. <el-select v-model="packageRequest.packageId" placeholder="请选择优惠包" v-if="packageRequest.packageType == 1" clearable>
  250. <el-option v-for="item in this.packageDiscountList" :key="item.id" :label="item.name" :value="item.id"></el-option>
  251. </el-select>
  252. <el-select v-model="packageRequest.packageId" placeholder="请选择佣金包" v-if="packageRequest.packageType == 2" clearable>
  253. <el-option v-for="item in this.packageCommissionList" :key="item.id" :label="item.name" :value="item.id"></el-option>
  254. </el-select>
  255. </el-form-item>
  256. </el-form>
  257. <div slot="footer" class="dialog-footer">
  258. <el-button type="primary" @click="submitFormPackage">确 定</el-button>
  259. <el-button @click="cancelPackage">取 消</el-button>
  260. </div>
  261. </el-dialog>
  262. </div>
  263. </template>
  264. <script>
  265. import { listAgent, getAgent, delAgent, addAgent, updateAgent, exportAgent } from "@/api/module/agent";
  266. import { getAgentLevelList } from "@/api/module/agentLevel";
  267. import Area from '@/components/area'
  268. import area from "@/api/city";
  269. import OldSend from '@/components/area/oldSend'
  270. export default {
  271. name: "Agent",
  272. components: {
  273. Area,
  274. OldSend
  275. },
  276. data() {
  277. return {
  278. // 登录用户
  279. user: {},
  280. // 允许的最大佣金比例
  281. maxRate: '',
  282. // 骑手最大佣金金额
  283. qishouMax: '',
  284. // 货拉拉最大佣金金额
  285. huolalaMax: '',
  286. // 绑定三方最大佣金金额
  287. bindingThirdMax: '',
  288. agentLevelList: [],
  289. areaProp: {},
  290. startArea: {
  291. province: '',
  292. city: '',
  293. district: '',
  294. provinceName: '',
  295. cityName: '',
  296. districtName: '',
  297. cityValues: [],
  298. districtValues: [],
  299. districtNames: [],
  300. //
  301. // province: '',
  302. // city: '',
  303. // district: '',
  304. // provinceName: '',
  305. // cityName: '',
  306. // districtName: ''
  307. },
  308. sendAreaProp: {},
  309. sendStartArea: {
  310. province: '',
  311. city: '',
  312. district: '',
  313. provinceName: '',
  314. cityName: '',
  315. districtName: '',
  316. cityValues: [],
  317. districtValues: [],
  318. districtNames: [],
  319. },
  320. // 遮罩层
  321. loading: true,
  322. // 选中数组
  323. ids: [],
  324. // 非单个禁用
  325. single: true,
  326. // 非多个禁用
  327. multiple: true,
  328. // 显示搜索条件
  329. showSearch: true,
  330. // 总条数
  331. total: 0,
  332. // 代理商表格数据
  333. agentList: [],
  334. // 弹出层标题
  335. title: "",
  336. // 是否显示弹出层
  337. open: false,
  338. date: [],
  339. // 查询参数
  340. queryParams: {
  341. pageNum: 1,
  342. pageSize: 10,
  343. name: undefined,
  344. pid: undefined,
  345. provinceId: undefined,
  346. cityId: undefined,
  347. districtId: undefined,
  348. agentLevel: undefined,
  349. commissionRate: undefined,
  350. contactName: undefined,
  351. avatar: undefined,
  352. mobile: undefined,
  353. address: undefined,
  354. remark: undefined,
  355. startTime: undefined,
  356. endTime: undefined
  357. },
  358. packageRequest: {
  359. packageType: undefined,
  360. packageId: undefined,
  361. agentId: undefined
  362. },
  363. packageRequestRules: {},
  364. packageRequestOpen: false,
  365. packageDeliveryList: [],
  366. packageCommissionList: [],
  367. packageDiscountList: [],
  368. // 表单参数
  369. form: {},
  370. // 表单校验
  371. rules: {
  372. commissionRate: [
  373. { required: true, message: "佣金比率不能为空", trigger: "blur" }
  374. ],
  375. name: [
  376. { required: true, message: "代理商名称不能为空", trigger: "blur" }
  377. ],
  378. agentLevel: [
  379. { required: true, message: "代理商等级不能为空", trigger: "blur" }
  380. ],
  381. provinceId: [
  382. { required: true, message: "所在省不能为空", trigger: "blur" }
  383. ],
  384. cityId: [
  385. { required: true, message: "所在城市不能为空", trigger: "blur" }
  386. ],
  387. districtId: [
  388. { required: true, message: "所在区不能为空", trigger: "blur" }
  389. ],
  390. contactName: [
  391. { required: true, message: "联系人不能为空", trigger: "blur" }
  392. ],
  393. mobile: [
  394. { required: true, message: "联系手机不能为空", trigger: "blur" }
  395. ],
  396. type: [
  397. { required: true, message: "佣金类型不能为空", trigger: "blur" }
  398. ],
  399. huolalaCommission: [
  400. { required: true, message: "货拉拉佣金金额不能为空", trigger: "blur" }
  401. ],
  402. bindingThirdCommission: [
  403. { required: true, message: "绑定三方运力佣金比例不能为空", trigger: "blur" }
  404. ],
  405. }
  406. };
  407. },
  408. created() {
  409. // 代理商登录跳转到代理商详情
  410. this.user = {type: '',name: ''}
  411. var type = localStorage.getItem("SYS_USER_TYPE")
  412. if(type == '0'){
  413. this.user.type = 0
  414. this.user.name = "系统"
  415. }
  416. if(type == '1'){
  417. this.user.type = 1
  418. this.user.name = "渠道商"
  419. }
  420. if(type == '2'){
  421. this.user.type = 2
  422. this.user.name = "代理商"
  423. }
  424. if (this.user.type == 2){
  425. this.$router.push({ path: '/agent/agent/info' })
  426. } else {
  427. // this.getUser()
  428. // alert(this.user.type)
  429. }
  430. this.getList();
  431. this.getMaxRate()
  432. this.getLevelList()
  433. this.$http.get("/module/packageDelivery/getDeliveryList").then(({ data }) => {
  434. this.packageDeliveryList = data
  435. })
  436. this.$http.get("/module/packageDiscount/getDiscountList").then(({ data }) => {
  437. this.packageDiscountList = data
  438. })
  439. this.$http.get("/module/packageCommission/getCommissionList").then(({ data }) => {
  440. this.packageCommissionList = data
  441. })
  442. },
  443. methods: {
  444. handleCommission(agentId, packageType) {
  445. this.packageRequest.agentId = agentId;
  446. this.packageRequest.packageType = packageType;
  447. getAgent(agentId).then(response => {
  448. this.packageRequest.packageId = response.data.packageCommissionId
  449. });
  450. this.packageRequestOpen = true;
  451. },
  452. handleDiscount(agentId, packageType) {
  453. this.packageRequest.agentId = agentId;
  454. this.packageRequest.packageType = packageType;
  455. getAgent(agentId).then(response => {
  456. this.packageRequest.packageId = response.data.packageDiscountId
  457. });
  458. this.packageRequestOpen = true;
  459. },
  460. changeSendArea(e) {
  461. this.sendStartArea = e
  462. },
  463. getLevelList(){
  464. getAgentLevelList().then(response => {
  465. this.agentLevelList = response.data
  466. })
  467. },
  468. getMaxRate(){
  469. this.$http
  470. .get(`/module/agent/getMaxRete`)
  471. .then(({
  472. data
  473. }) => {
  474. if (data) {
  475. console.log('maxrate', data)
  476. this.maxRate = data.maxRate
  477. this.qishouMax = data.qishouMax
  478. this.huolalaMax = data.huolalaMax
  479. // this.bindingThirdMax = data.bindingThirdMax
  480. // this.maxRate = data
  481. }
  482. })
  483. },
  484. gotoInfo(id){
  485. this.$router.push({ path: '/agent/agent/info', query: { id: id } })
  486. },
  487. // 选择区域
  488. changeArea (e) {
  489. this.startArea = e
  490. // this.$http.get('/module/bindDeliveryConfig/getBindingThirdMax?cityId=' + this.startArea.city).then(( { data } ) => {
  491. // console.log('data', data)
  492. // this.bindingThirdMax = data
  493. // console.log('bindMinFee', this.bindingThirdMax)
  494. // })
  495. },
  496. /** 查询代理商列表 */
  497. getList() {
  498. if (this.user.type == 2){
  499. this.$router.push({ path: '/agent/agent/info' })
  500. }
  501. this.loading = true;
  502. if(null != this.date && "" != this.date) {
  503. this.queryParams.startTime = this.date[0];
  504. this.queryParams.endTime = this.date[1];
  505. }else {
  506. this.queryParams.startTime = "";
  507. this.queryParams.endTime = "";
  508. }
  509. listAgent(this.queryParams).then(response => {
  510. this.agentList = response.rows;
  511. this.total = response.total;
  512. this.loading = false;
  513. });
  514. },
  515. // 取消按钮
  516. cancel() {
  517. this.open = false;
  518. this.reset();
  519. },
  520. cancelPackage() {
  521. this.packageRequestOpen = false;
  522. this.packageRequest = {
  523. packageType: undefined,
  524. packageId: undefined,
  525. agentId: undefined
  526. };
  527. },
  528. // 表单重置
  529. reset() {
  530. this.form = {
  531. id: undefined,
  532. name: undefined,
  533. pid: undefined,
  534. provinceId: undefined,
  535. cityId: undefined,
  536. districtId: undefined,
  537. agentLevel: undefined,
  538. commissionRate: undefined,
  539. contactName: undefined,
  540. avatar: undefined,
  541. mobile: undefined,
  542. address: undefined,
  543. provinceName: undefined,
  544. cityName: undefined,
  545. districtName: undefined,
  546. mobilePhone: undefined,
  547. isPid: undefined,
  548. remark: undefined,
  549. type: 0,
  550. huolalaCommission: undefined,
  551. bindingThirdCommission: undefined,
  552. packageDiscountId: undefined,
  553. packageCommissionid: undefined
  554. };
  555. this.resetForm("form");
  556. this.startArea = {
  557. province: '',
  558. city: '',
  559. district: '',
  560. provinceName: '',
  561. cityName: '',
  562. districtName: '',
  563. cityValues: [],
  564. districtValues: [],
  565. districtNames: [],
  566. };
  567. this.areaProp = {}
  568. },
  569. /** 搜索按钮操作 */
  570. handleQuery() {
  571. this.queryParams.pageNum = 1;
  572. this.queryParams.provinceName = this.sendStartArea.provinceName
  573. this.queryParams.cityName = this.sendStartArea.cityName
  574. this.queryParams.districtName = this.sendStartArea.districtName
  575. this.getList();
  576. },
  577. /** 重置按钮操作 */
  578. resetQuery() {
  579. this.resetForm("queryForm");
  580. this.date = []
  581. this.queryParams.startTime = ""
  582. this.queryParams.endTime = ""
  583. this.sendStartArea = {
  584. province: '',
  585. city: '',
  586. district: '',
  587. provinceName: '',
  588. cityName: '',
  589. districtName: '',
  590. cityValues: [],
  591. districtValues: [],
  592. districtNames: [],
  593. };
  594. this.sendAreaProp = {}
  595. this.handleQuery();
  596. },
  597. // 多选框选中数据
  598. handleSelectionChange(selection) {
  599. this.ids = selection.map(item => item.id)
  600. this.single = selection.length!==1
  601. this.multiple = !selection.length
  602. },
  603. /** 新增按钮操作 */
  604. handleAdd() {
  605. this.reset();
  606. this.open = true;
  607. this.title = "添加代理商";
  608. },
  609. /** 修改按钮操作 */
  610. handleUpdate(row) {
  611. this.reset();
  612. const id = row.id || this.ids
  613. getAgent(id).then(response => {
  614. this.form = response.data;
  615. this.form.mobilePhone = response.data.mobile
  616. this.startArea.province = response.data.provinceId
  617. this.startArea.district = response.data.districtId
  618. this.startArea.city = response.data.cityId
  619. this.startArea.provinceName = response.data.provinceName
  620. this.startArea.cityName = response.data.cityName
  621. this.startArea.districtName = response.data.districtName
  622. this.startArea.district = this.startArea.district.split(",");
  623. this.bindingThirdMax = response.data.bindingThirdMax
  624. area.area.forEach(v => {
  625. if (v.id === this.startArea.province) {
  626. this.startArea.cityValues = v.childs
  627. }
  628. })
  629. this.startArea.cityValues.forEach(v =>{
  630. if (v.id === this.startArea.city) {
  631. this.startArea.districtValues = v.childs
  632. }
  633. })
  634. this.areaProp = JSON.parse(JSON.stringify(this.startArea))
  635. this.open = true;
  636. this.title = "修改代理商";
  637. });
  638. },
  639. /** 提交按钮 */
  640. submitForm() {
  641. this.$refs["form"].validate(valid => {
  642. if (valid) {
  643. if (this.startArea.province === undefined || this.startArea.city === undefined || this.startArea.district === undefined) {
  644. this.$message({
  645. message: '请选择地区',
  646. type: 'error',
  647. duration: 1500
  648. })
  649. return
  650. }
  651. this.form.provinceId = this.startArea.province
  652. this.form.cityId = this.startArea.city
  653. this.form.districtId = this.startArea.district.join(",")
  654. this.form.provinceName = this.startArea.provinceName
  655. this.form.cityName = this.startArea.cityName
  656. this.form.districtName = this.startArea.districtName
  657. if (this.form.id != null) {
  658. updateAgent(this.form).then(response => {
  659. this.msgSuccess("修改成功");
  660. this.open = false;
  661. this.getList();
  662. });
  663. } else {
  664. console.log(this.form)
  665. addAgent(this.form).then(response => {
  666. this.msgSuccess("新增成功");
  667. this.open = false;
  668. this.getList();
  669. });
  670. }
  671. }
  672. });
  673. },
  674. submitFormPackage() {
  675. this.$refs["packageRequest"].validate(valid => {
  676. if (valid) {
  677. if(this.packageRequest.packageType == 1) {
  678. this.$http.post('/module/agent/bindDiscountPackage', this.packageRequest).then(( { data }) => {
  679. if(data) {
  680. this.$message.success('绑定成功!');
  681. this.packageRequestOpen = false;
  682. this.getList();
  683. }
  684. })
  685. }
  686. if(this.packageRequest.packageType == 2) {
  687. this.$http.post('/module/agent/bindCommissionPackage', this.packageRequest).then(( { data }) => {
  688. if(data) {
  689. this.$message.success('绑定成功!');
  690. this.packageRequestOpen = false;
  691. this.getList();
  692. }
  693. })
  694. }
  695. }
  696. })
  697. },
  698. /** 删除按钮操作 */
  699. handleDelete(row) {
  700. const ids = row.id || this.ids;
  701. this.$confirm('是否确认删除代理商编号为"' + ids + '"的数据项?', "警告", {
  702. confirmButtonText: "确定",
  703. cancelButtonText: "取消",
  704. type: "warning"
  705. }).then(function() {
  706. return delAgent(ids);
  707. }).then(() => {
  708. this.getList();
  709. this.msgSuccess("删除成功");
  710. })
  711. },
  712. /** 导出按钮操作 */
  713. handleExport() {
  714. const queryParams = this.queryParams;
  715. this.$confirm('是否确认导出所有代理商数据项?', "警告", {
  716. confirmButtonText: "确定",
  717. cancelButtonText: "取消",
  718. type: "warning"
  719. }).then(function() {
  720. return exportAgent(queryParams);
  721. }).then(response => {
  722. this.download(response.msg);
  723. })
  724. }
  725. }
  726. };
  727. </script>